diff --git a/src/cli/Baseten.CLI/Commands/ApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/ApiCommand.g.cs index a2c07aa..2476965 100644 --- a/src/cli/Baseten.CLI/Commands/ApiCommand.g.cs +++ b/src/cli/Baseten.CLI/Commands/ApiCommand.g.cs @@ -14,6 +14,7 @@ public static Command Create() command.Subcommands.Add(DefaultApiGroupCommand.Create()); command.Subcommands.Add(ImagesApiGroupCommand.Create()); + command.Subcommands.Add(PreviewsApiGroupCommand.Create()); command.Subcommands.Add(SandboxesApiGroupCommand.Create()); CustomizeCommand(ref command); return command; diff --git a/src/cli/Baseten.CLI/Commands/PreviewsApiGroupCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsApiGroupCommand.g.cs new file mode 100644 index 0000000..5fc45b7 --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsApiGroupCommand.g.cs @@ -0,0 +1,25 @@ +#nullable enable + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsApiGroupCommand +{ + static partial void CustomizeCommand(ref Command command); + + public static Command Create() + { + var command = new Command(@"previews", @"Previews endpoint commands."); + command.Subcommands.Add(PreviewsCreateSandboxPreviewCommandApiCommand.Create()); + command.Subcommands.Add(PreviewsCreateSandboxPreviewTokenCommandApiCommand.Create()); + command.Subcommands.Add(PreviewsDeleteSandboxPreviewCommandApiCommand.Create()); + command.Subcommands.Add(PreviewsDeleteSandboxPreviewTokenCommandApiCommand.Create()); + command.Subcommands.Add(PreviewsGetSandboxPreviewCommandApiCommand.Create()); + command.Subcommands.Add(PreviewsListSandboxPreviewTokensCommandApiCommand.Create()); + command.Subcommands.Add(PreviewsListSandboxPreviewsCommandApiCommand.Create()); + command.Subcommands.Add(PreviewsUpdateSandboxPreviewCommandApiCommand.Create()); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/cli/Baseten.CLI/Commands/PreviewsCreateSandboxPreviewCommandApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsCreateSandboxPreviewCommandApiCommand.g.cs new file mode 100644 index 0000000..e81ca9c --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsCreateSandboxPreviewCommandApiCommand.g.cs @@ -0,0 +1,122 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsCreateSandboxPreviewCommandApiCommand +{ + private static Argument SandboxName { get; } = new( + name: @"sandbox-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Option TeamId { get; } = new( + name: @"--team-id") + { + Description = @"Optional team ID. Must match X-Team-Id when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option XTeamId { get; } = new( + name: @"--x-team-id") + { + Description = @"Optional team ID. Must match the team_id query parameter when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + private static Option Input { get; } = new(@"--input") + { + Description = "Load request JSON from a file path, '-' for stdin, or an inline JSON object/array string.", + }; + + private static Option RequestJson { get; } = new(@"--request-json") + { + Description = "Request body as JSON.", + Hidden = true, + }; + + private static Option RequestFile { get; } = new(@"--request-file") + { + Description = "Path to a JSON request file, or '-' for stdin.", + Hidden = true, + }; + + private static string FormatResponse(ParseResult parseResult, global::Baseten.SandboxPreviewV1 value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings) + { + string? text = null; + CustomizeResponseText(parseResult, value, ref text); + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + + var hints = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + }; + CustomizeResponseFormatHints(hints); + return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints); + } + + static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.SandboxPreviewV1 value, ref string? text); + static partial void CustomizeResponseFormatHints(Dictionary hints); + + + static partial void CustomizeCommand(ref Command command); + + public static Command Create(string? commandName = null) + { + var command = new Command(commandName ?? @"create-sandbox-preview", @"Create a sandbox preview +Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox's reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public-<port> or private-<port> when create_if_not_exists is true."); + command.Arguments.Add(SandboxName); + command.Options.Add(TeamId); + command.Options.Add(XTeamId); + command.Options.Add(Input); + command.Options.Add(RequestJson); + command.Options.Add(RequestFile); + command.Validators.Add(result => + { + var hasInput = result.GetResult(Input) is not null; + var hasRequestJson = result.GetResult(RequestJson) is not null; + var hasRequestFile = result.GetResult(RequestFile) is not null; + var specifiedCount = (hasInput ? 1 : 0) + (hasRequestJson ? 1 : 0) + (hasRequestFile ? 1 : 0); + if (specifiedCount != 1) + { + result.AddError(@"Specify exactly one of --input, --request-json, or --request-file."); + } + }); + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var sandboxName = parseResult.GetRequiredValue(SandboxName); + var teamId = parseResult.GetValue(TeamId); + var xTeamId = parseResult.GetValue(XTeamId); + var request = await CliRuntime.ReadRequestAsync( + parseResult, + Input, + RequestJson, + RequestFile, + global::Baseten.SourceGenerationContext.Default, + cancellationToken).ConfigureAwait(false); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Previews.CreateSandboxPreviewAsync( + sandboxName: sandboxName, + teamId: teamId, + xTeamId: xTeamId, + request: request, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/cli/Baseten.CLI/Commands/PreviewsCreateSandboxPreviewTokenCommandApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsCreateSandboxPreviewTokenCommandApiCommand.g.cs new file mode 100644 index 0000000..c45eee4 --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsCreateSandboxPreviewTokenCommandApiCommand.g.cs @@ -0,0 +1,147 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsCreateSandboxPreviewTokenCommandApiCommand +{ + private static Argument SandboxName { get; } = new( + name: @"sandbox-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Argument PreviewName { get; } = new( + name: @"preview-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Option TeamId { get; } = new( + name: @"--team-id") + { + Description = @"Optional team ID. Must match X-Team-Id when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option XTeamId { get; } = new( + name: @"--x-team-id") + { + Description = @"Optional team ID. Must match the team_id query parameter when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option CreateIfNotExists { get; } = CliRuntime.CreateNullableBoolOption( + name: @"--create-if-not-exists", + description: @"When true, return an existing unexpired token of this preview that stays valid at least until expires_at instead of creating a new one. Defaults to false when omitted."); + + private static Option ExpiresAt { get; } = new( + name: @"--expires-at") + { + Description = @"Time at which the token stops working. Must be in the future.", + Required = true, + }; + private static Option Input { get; } = new(@"--input") + { + Description = "Load request JSON from a file path, '-' for stdin, or an inline JSON object/array string.", + }; + + private static Option RequestJson { get; } = new(@"--request-json") + { + Description = "Request body as JSON.", + Hidden = true, + }; + + private static Option RequestFile { get; } = new(@"--request-file") + { + Description = "Path to a JSON request file, or '-' for stdin.", + Hidden = true, + }; + + private static string FormatResponse(ParseResult parseResult, global::Baseten.SandboxPreviewTokenV1 value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings) + { + string? text = null; + CustomizeResponseText(parseResult, value, ref text); + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + + var hints = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + }; + CustomizeResponseFormatHints(hints); + return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints); + } + + static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.SandboxPreviewTokenV1 value, ref string? text); + static partial void CustomizeResponseFormatHints(Dictionary hints); + + + static partial void CustomizeCommand(ref Command command); + + public static Command Create(string? commandName = null) + { + var command = new Command(commandName ?? @"create-sandbox-preview-token", @"Create a preview token +Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=<token>."); + command.Arguments.Add(SandboxName); + command.Arguments.Add(PreviewName); + command.Options.Add(TeamId); + command.Options.Add(XTeamId); + command.Options.Add(CreateIfNotExists); + command.Options.Add(ExpiresAt); + command.Options.Add(Input); + command.Options.Add(RequestJson); + command.Options.Add(RequestFile); + command.Validators.Add(result => + { + var hasInput = result.GetResult(Input) is not null; + var hasRequestJson = result.GetResult(RequestJson) is not null; + var hasRequestFile = result.GetResult(RequestFile) is not null; + var specifiedCount = (hasInput ? 1 : 0) + (hasRequestJson ? 1 : 0) + (hasRequestFile ? 1 : 0); + if (specifiedCount > 1) + { + result.AddError(@"Specify at most one of --input, --request-json, or --request-file."); + } + }); + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync( + parseResult, + Input, + RequestJson, + RequestFile, + global::Baseten.SourceGenerationContext.Default, + cancellationToken).ConfigureAwait(false); + var sandboxName = parseResult.GetRequiredValue(SandboxName); + var previewName = parseResult.GetRequiredValue(PreviewName); + var teamId = parseResult.GetValue(TeamId); + var xTeamId = parseResult.GetValue(XTeamId); + var createIfNotExists = CliRuntime.WasSpecified(parseResult, CreateIfNotExists) ? parseResult.GetValue(CreateIfNotExists) : (__requestBase is { } __CreateIfNotExistsBaseValue ? __CreateIfNotExistsBaseValue.CreateIfNotExists : default); + var expiresAt = parseResult.GetRequiredValue(ExpiresAt); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Previews.CreateSandboxPreviewTokenAsync( + sandboxName: sandboxName, + previewName: previewName, + teamId: teamId, + xTeamId: xTeamId, + createIfNotExists: createIfNotExists, + expiresAt: expiresAt, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/cli/Baseten.CLI/Commands/PreviewsDeleteSandboxPreviewCommandApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsDeleteSandboxPreviewCommandApiCommand.g.cs new file mode 100644 index 0000000..474d952 --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsDeleteSandboxPreviewCommandApiCommand.g.cs @@ -0,0 +1,94 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsDeleteSandboxPreviewCommandApiCommand +{ + private static Argument SandboxName { get; } = new( + name: @"sandbox-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Argument PreviewName { get; } = new( + name: @"preview-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Option TeamId { get; } = new( + name: @"--team-id") + { + Description = @"Optional team ID. Must match X-Team-Id when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option XTeamId { get; } = new( + name: @"--x-team-id") + { + Description = @"Optional team ID. Must match the team_id query parameter when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static string FormatResponse(ParseResult parseResult, global::Baseten.SandboxPreviewV1 value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings) + { + string? text = null; + CustomizeResponseText(parseResult, value, ref text); + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + + var hints = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + }; + CustomizeResponseFormatHints(hints); + return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints); + } + + static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.SandboxPreviewV1 value, ref string? text); + static partial void CustomizeResponseFormatHints(Dictionary hints); + + + static partial void CustomizeCommand(ref Command command); + + public static Command Create(string? commandName = null) + { + var command = new Command(commandName ?? @"delete-sandbox-preview", @"Delete a sandbox preview +Delete the preview and revoke its tokens. The URL stops serving immediately. Return the deleted preview, with status TERMINATED, or DELETING while a preview with many tokens finishes in the background."); + command.Arguments.Add(SandboxName); + command.Arguments.Add(PreviewName); + command.Options.Add(TeamId); + command.Options.Add(XTeamId); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var sandboxName = parseResult.GetRequiredValue(SandboxName); + var previewName = parseResult.GetRequiredValue(PreviewName); + var teamId = parseResult.GetValue(TeamId); + var xTeamId = parseResult.GetValue(XTeamId); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Previews.DeleteSandboxPreviewAsync( + sandboxName: sandboxName, + previewName: previewName, + teamId: teamId, + xTeamId: xTeamId, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/cli/Baseten.CLI/Commands/PreviewsDeleteSandboxPreviewTokenCommandApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsDeleteSandboxPreviewTokenCommandApiCommand.g.cs new file mode 100644 index 0000000..1e0d9dc --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsDeleteSandboxPreviewTokenCommandApiCommand.g.cs @@ -0,0 +1,77 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsDeleteSandboxPreviewTokenCommandApiCommand +{ + private static Argument SandboxName { get; } = new( + name: @"sandbox-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Argument PreviewName { get; } = new( + name: @"preview-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Argument TokenName { get; } = new( + name: @"token-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Option TeamId { get; } = new( + name: @"--team-id") + { + Description = @"Optional team ID. Must match X-Team-Id when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option XTeamId { get; } = new( + name: @"--x-team-id") + { + Description = @"Optional team ID. Must match the team_id query parameter when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + static partial void CustomizeCommand(ref Command command); + + public static Command Create(string? commandName = null) + { + var command = new Command(commandName ?? @"delete-sandbox-preview-token", @"Delete a preview token +Revoke the token. Requests using it are rejected immediately."); + command.Arguments.Add(SandboxName); + command.Arguments.Add(PreviewName); + command.Arguments.Add(TokenName); + command.Options.Add(TeamId); + command.Options.Add(XTeamId); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var sandboxName = parseResult.GetRequiredValue(SandboxName); + var previewName = parseResult.GetRequiredValue(PreviewName); + var tokenName = parseResult.GetRequiredValue(TokenName); + var teamId = parseResult.GetValue(TeamId); + var xTeamId = parseResult.GetValue(XTeamId); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + await client.Previews.DeleteSandboxPreviewTokenAsync( + sandboxName: sandboxName, + previewName: previewName, + tokenName: tokenName, + teamId: teamId, + xTeamId: xTeamId, + cancellationToken: cancellationToken).ConfigureAwait(false); + + await CliRuntime.WriteSuccessAsync(parseResult, cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/cli/Baseten.CLI/Commands/PreviewsGetSandboxPreviewCommandApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsGetSandboxPreviewCommandApiCommand.g.cs new file mode 100644 index 0000000..5174aed --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsGetSandboxPreviewCommandApiCommand.g.cs @@ -0,0 +1,101 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsGetSandboxPreviewCommandApiCommand +{ + private static Argument SandboxName { get; } = new( + name: @"sandbox-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Argument PreviewName { get; } = new( + name: @"preview-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Option TeamId { get; } = new( + name: @"--team-id") + { + Description = @"Optional team ID. Must match X-Team-Id when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option XTeamId { get; } = new( + name: @"--x-team-id") + { + Description = @"Optional team ID. Must match the team_id query parameter when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option ShowSecrets { get; } = CliRuntime.CreateNullableBoolOption( + name: @"--show-secrets", + description: @"Reveal request header values for workspace administrators, for example to change one header and send the full set back in a PATCH. Defaults to false. Callers without the admin role receive masked values even when true."); + + private static string FormatResponse(ParseResult parseResult, global::Baseten.SandboxPreviewV1 value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings) + { + string? text = null; + CustomizeResponseText(parseResult, value, ref text); + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + + var hints = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + }; + CustomizeResponseFormatHints(hints); + return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints); + } + + static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.SandboxPreviewV1 value, ref string? text); + static partial void CustomizeResponseFormatHints(Dictionary hints); + + + static partial void CustomizeCommand(ref Command command); + + public static Command Create(string? commandName = null) + { + var command = new Command(commandName ?? @"get-sandbox-preview", @"Get a sandbox preview +Return the preview configuration, URL and status."); + command.Arguments.Add(SandboxName); + command.Arguments.Add(PreviewName); + command.Options.Add(TeamId); + command.Options.Add(XTeamId); + command.Options.Add(ShowSecrets); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var sandboxName = parseResult.GetRequiredValue(SandboxName); + var previewName = parseResult.GetRequiredValue(PreviewName); + var teamId = parseResult.GetValue(TeamId); + var xTeamId = parseResult.GetValue(XTeamId); + var showSecrets = parseResult.GetValue(ShowSecrets); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Previews.GetSandboxPreviewAsync( + sandboxName: sandboxName, + previewName: previewName, + teamId: teamId, + xTeamId: xTeamId, + showSecrets: showSecrets, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/cli/Baseten.CLI/Commands/PreviewsListSandboxPreviewTokensCommandApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsListSandboxPreviewTokensCommandApiCommand.g.cs new file mode 100644 index 0000000..c4fe260 --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsListSandboxPreviewTokensCommandApiCommand.g.cs @@ -0,0 +1,120 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsListSandboxPreviewTokensCommandApiCommand +{ + private static Argument SandboxName { get; } = new( + name: @"sandbox-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Argument PreviewName { get; } = new( + name: @"preview-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Option TeamId { get; } = new( + name: @"--team-id") + { + Description = @"Optional team ID. Must match X-Team-Id when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option XTeamId { get; } = new( + name: @"--x-team-id") + { + Description = @"Optional team ID. Must match the team_id query parameter when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option Cursor { get; } = new( + name: @"--cursor") + { + Description = @"Opaque cursor from the previous page; omit for the first page.", + }; + + private static Option Limit { get; } = new( + name: @"--limit") + { + Description = @"Maximum number of items to return.", + }; + + private static string FormatResponse(ParseResult parseResult, global::Baseten.ListSandboxPreviewTokensResponseV1 value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings) + { + string? text = null; + CustomizeResponseText(parseResult, value, ref text); + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + + var hints = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + }; + CustomizeResponseFormatHints(hints); + return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints); + } + + static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.ListSandboxPreviewTokensResponseV1 value, ref string? text); + static partial void CustomizeResponseFormatHints(Dictionary hints); + + + static partial void CustomizeCommand(ref Command command); + + public static Command Create(string? commandName = null) + { + var command = new Command(commandName ?? @"list-sandbox-preview-tokens", @"List preview tokens +Return the tokens of a private preview in the paginated list format, including expired tokens until they are removed. cursor and limit are accepted but not applied yet; all tokens fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied."); + command.Arguments.Add(SandboxName); + command.Arguments.Add(PreviewName); + command.Options.Add(TeamId); + command.Options.Add(XTeamId); + command.Options.Add(Cursor); + command.Options.Add(Limit); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var sandboxName = parseResult.GetRequiredValue(SandboxName); + var previewName = parseResult.GetRequiredValue(PreviewName); + var teamId = parseResult.GetValue(TeamId); + var xTeamId = parseResult.GetValue(XTeamId); + var cursor = parseResult.GetValue(Cursor); + var limit = parseResult.GetValue(Limit); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Previews.ListSandboxPreviewTokensAsync( + sandboxName: sandboxName, + previewName: previewName, + teamId: teamId, + xTeamId: xTeamId, + cursor: cursor, + limit: limit, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + if (!await CliRuntime.TryWriteOutputDirectoryAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + @"Items", + cancellationToken).ConfigureAwait(false)) + { + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + } + }, cancellationToken).ConfigureAwait(false)); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/cli/Baseten.CLI/Commands/PreviewsListSandboxPreviewsCommandApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsListSandboxPreviewsCommandApiCommand.g.cs new file mode 100644 index 0000000..b418b28 --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsListSandboxPreviewsCommandApiCommand.g.cs @@ -0,0 +1,111 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsListSandboxPreviewsCommandApiCommand +{ + private static Argument SandboxName { get; } = new( + name: @"sandbox-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Option TeamId { get; } = new( + name: @"--team-id") + { + Description = @"Optional team ID. Must match X-Team-Id when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option XTeamId { get; } = new( + name: @"--x-team-id") + { + Description = @"Optional team ID. Must match the team_id query parameter when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option Cursor { get; } = new( + name: @"--cursor") + { + Description = @"Opaque cursor from the previous page; omit for the first page.", + }; + + private static Option Limit { get; } = new( + name: @"--limit") + { + Description = @"Maximum number of items to return.", + }; + + private static string FormatResponse(ParseResult parseResult, global::Baseten.ListSandboxPreviewsResponseV1 value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings) + { + string? text = null; + CustomizeResponseText(parseResult, value, ref text); + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + + var hints = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + }; + CustomizeResponseFormatHints(hints); + return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints); + } + + static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.ListSandboxPreviewsResponseV1 value, ref string? text); + static partial void CustomizeResponseFormatHints(Dictionary hints); + + + static partial void CustomizeCommand(ref Command command); + + public static Command Create(string? commandName = null) + { + var command = new Command(commandName ?? @"list-sandbox-previews", @"List sandbox previews +Return the previews of the sandbox in the paginated list format. cursor and limit are accepted but not applied yet; all previews fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied."); + command.Arguments.Add(SandboxName); + command.Options.Add(TeamId); + command.Options.Add(XTeamId); + command.Options.Add(Cursor); + command.Options.Add(Limit); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var sandboxName = parseResult.GetRequiredValue(SandboxName); + var teamId = parseResult.GetValue(TeamId); + var xTeamId = parseResult.GetValue(XTeamId); + var cursor = parseResult.GetValue(Cursor); + var limit = parseResult.GetValue(Limit); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Previews.ListSandboxPreviewsAsync( + sandboxName: sandboxName, + teamId: teamId, + xTeamId: xTeamId, + cursor: cursor, + limit: limit, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + if (!await CliRuntime.TryWriteOutputDirectoryAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + @"Items", + cancellationToken).ConfigureAwait(false)) + { + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + } + }, cancellationToken).ConfigureAwait(false)); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/cli/Baseten.CLI/Commands/PreviewsUpdateSandboxPreviewCommandApiCommand.g.cs b/src/cli/Baseten.CLI/Commands/PreviewsUpdateSandboxPreviewCommandApiCommand.g.cs new file mode 100644 index 0000000..04feee5 --- /dev/null +++ b/src/cli/Baseten.CLI/Commands/PreviewsUpdateSandboxPreviewCommandApiCommand.g.cs @@ -0,0 +1,137 @@ +#nullable enable +#pragma warning disable CS0618 + +using System.CommandLine; + +namespace Baseten.CLI.Commands; + +internal static partial class PreviewsUpdateSandboxPreviewCommandApiCommand +{ + private static Argument SandboxName { get; } = new( + name: @"sandbox-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Argument PreviewName { get; } = new( + name: @"preview-name") + { + Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.", + }; + + private static Option TeamId { get; } = new( + name: @"--team-id") + { + Description = @"Optional team ID. Must match X-Team-Id when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option XTeamId { get; } = new( + name: @"--x-team-id") + { + Description = @"Optional team ID. Must match the team_id query parameter when both are supplied. If neither selector is supplied, defaults to the caller's only accessible team. Callers with multiple accessible teams must select a team. Requests without access to any team are forbidden.", + }; + + private static Option Public { get; } = CliRuntime.CreateNullableBoolOption( + name: @"--public", + description: @"Whether the URL is reachable without a preview token. Defaults to false."); + + private static Option?> ResponseHeaders { get; } = new( + name: @"--response-headers") + { + Description = @"Headers added to every response served by the preview, for example CORS headers.", + }; + + private static Option?> RequestHeaders { get; } = new( + name: @"--request-headers") + { + Description = @"Headers added to every request forwarded to the sandbox, for example an Authorization header expected by the application. Responses return each name with the value ""****"", except a GET with show_secrets=true by a workspace administrator. Sending ""****"" back as a value returns 400. A PATCH replaces the whole set.", + }; + + private static Option Ttl { get; } = new( + name: @"--ttl") + { + Description = @"Lifetime counted from the request, using seconds, minutes, hours or composite durations such as 1h30m. Whole days are also supported, for example 7d; days cannot be combined with other units. The preview is deleted when it elapses.", + }; + + private static Option ExpiresAt { get; } = new( + name: @"--expires-at") + { + Description = @"Time at which the preview is deleted. Must be in the future.", + }; + + private static string FormatResponse(ParseResult parseResult, global::Baseten.SandboxPreviewV1 value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings) + { + string? text = null; + CustomizeResponseText(parseResult, value, ref text); + if (!string.IsNullOrWhiteSpace(text)) + { + return text; + } + + var hints = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + }; + CustomizeResponseFormatHints(hints); + return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints); + } + + static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.SandboxPreviewV1 value, ref string? text); + static partial void CustomizeResponseFormatHints(Dictionary hints); + + + static partial void CustomizeCommand(ref Command command); + + public static Command Create(string? commandName = null) + { + var command = new Command(commandName ?? @"update-sandbox-preview", @"Update a sandbox preview +Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400."); + command.Arguments.Add(SandboxName); + command.Arguments.Add(PreviewName); + command.Options.Add(TeamId); + command.Options.Add(XTeamId); + command.Options.Add(Public); + command.Options.Add(ResponseHeaders); + command.Options.Add(RequestHeaders); + command.Options.Add(Ttl); + command.Options.Add(ExpiresAt); + + + command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) => + await CliRuntime.RunAsync(async () => + { + var sandboxName = parseResult.GetRequiredValue(SandboxName); + var previewName = parseResult.GetRequiredValue(PreviewName); + var teamId = parseResult.GetValue(TeamId); + var xTeamId = parseResult.GetValue(XTeamId); + var @public = parseResult.GetValue(Public); + var responseHeaders = parseResult.GetValue(ResponseHeaders); + var requestHeaders = parseResult.GetValue(RequestHeaders); + var ttl = parseResult.GetValue(Ttl); + var expiresAt = parseResult.GetValue(ExpiresAt); + using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false); + + + var response = await client.Previews.UpdateSandboxPreviewAsync( + sandboxName: sandboxName, + previewName: previewName, + teamId: teamId, + xTeamId: xTeamId, + @public: @public, + responseHeaders: responseHeaders, + requestHeaders: requestHeaders, + ttl: ttl, + expiresAt: expiresAt, + cancellationToken: cancellationToken).ConfigureAwait(false); + + + await CliRuntime.WriteResponseAsync( + parseResult, + response, + global::Baseten.SourceGenerationContext.Default, + FormatResponse, + cancellationToken).ConfigureAwait(false); + }, cancellationToken).ConfigureAwait(false)); + CustomizeCommand(ref command); + return command; + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.BasetenClient.g.cs b/src/libs/Baseten/Generated/Baseten.BasetenClient.g.cs index ee61f9e..047081b 100644 --- a/src/libs/Baseten/Generated/Baseten.BasetenClient.g.cs +++ b/src/libs/Baseten/Generated/Baseten.BasetenClient.g.cs @@ -56,6 +56,15 @@ public sealed partial class BasetenClient : global::Baseten.IBasetenClient, glob JsonSerializerContextProvider = JsonSerializerContextProvider, }; + /// + /// + /// + public PreviewsClient Previews => new PreviewsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) + { + ReadResponseAsString = ReadResponseAsString, + JsonSerializerContextProvider = JsonSerializerContextProvider, + }; + /// /// /// diff --git a/src/libs/Baseten/Generated/Baseten.IBasetenClient.g.cs b/src/libs/Baseten/Generated/Baseten.IBasetenClient.g.cs index 8e042c1..45d122f 100644 --- a/src/libs/Baseten/Generated/Baseten.IBasetenClient.g.cs +++ b/src/libs/Baseten/Generated/Baseten.IBasetenClient.g.cs @@ -50,6 +50,11 @@ public partial interface IBasetenClient : global::System.IDisposable /// public ImagesClient Images { get; } + /// + /// + /// + public PreviewsClient Previews { get; } + /// /// /// diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.Authorizations.Bearer.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.Authorizations.Bearer.g.cs new file mode 100644 index 0000000..1fe8627 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.Authorizations.Bearer.g.cs @@ -0,0 +1,16 @@ + +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// Authorize using bearer authentication. + /// + /// + + public void AuthorizeUsingBearer( + string apiKey); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.CreateSandboxPreview.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.CreateSandboxPreview.g.cs new file mode 100644 index 0000000..5fee389 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.CreateSandboxPreview.g.cs @@ -0,0 +1,62 @@ +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// Create a sandbox preview
+ /// Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox's reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public-<port> or private-<port> when create_if_not_exists is true. + ///
+ /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreateSandboxPreviewAsync( + string sandboxName, + + global::Baseten.CreateSandboxPreviewRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a sandbox preview
+ /// Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox's reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public-<port> or private-<port> when create_if_not_exists is true. + ///
+ /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateSandboxPreviewAsResponseAsync( + string sandboxName, + + global::Baseten.CreateSandboxPreviewRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a sandbox preview
+ /// Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox's reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public-<port> or private-<port> when create_if_not_exists is true. + ///
+ /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreateSandboxPreviewAsync( + string sandboxName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.CreateSandboxPreviewToken.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.CreateSandboxPreviewToken.g.cs new file mode 100644 index 0000000..178411c --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.CreateSandboxPreviewToken.g.cs @@ -0,0 +1,77 @@ +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// Create a preview token
+ /// Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=<token>. + ///
+ /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreateSandboxPreviewTokenAsync( + string sandboxName, + string previewName, + + global::Baseten.CreateSandboxPreviewTokenRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a preview token
+ /// Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=<token>. + ///
+ /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateSandboxPreviewTokenAsResponseAsync( + string sandboxName, + string previewName, + + global::Baseten.CreateSandboxPreviewTokenRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a preview token
+ /// Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=<token>. + ///
+ /// + /// + /// + /// + /// + /// When true, return an existing unexpired token of this preview that stays valid at least until expires_at instead of creating a new one. Defaults to false when omitted. + /// + /// + /// Time at which the token stops working. Must be in the future.
+ /// Example: 2026-10-13T12:00:00Z + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreateSandboxPreviewTokenAsync( + string sandboxName, + string previewName, + global::System.DateTime expiresAt, + string? teamId = default, + string? xTeamId = default, + bool? createIfNotExists = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.DeleteSandboxPreview.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.DeleteSandboxPreview.g.cs new file mode 100644 index 0000000..a6d6735 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.DeleteSandboxPreview.g.cs @@ -0,0 +1,44 @@ +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// Delete a sandbox preview
+ /// Delete the preview and revoke its tokens. The URL stops serving immediately. Return the deleted preview, with status TERMINATED, or DELETING while a preview with many tokens finishes in the background. + ///
+ /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task DeleteSandboxPreviewAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a sandbox preview
+ /// Delete the preview and revoke its tokens. The URL stops serving immediately. Return the deleted preview, with status TERMINATED, or DELETING while a preview with many tokens finishes in the background. + ///
+ /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> DeleteSandboxPreviewAsResponseAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.DeleteSandboxPreviewToken.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.DeleteSandboxPreviewToken.g.cs new file mode 100644 index 0000000..ba0abd8 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.DeleteSandboxPreviewToken.g.cs @@ -0,0 +1,48 @@ +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// Delete a preview token
+ /// Revoke the token. Requests using it are rejected immediately. + ///
+ /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task DeleteSandboxPreviewTokenAsync( + string sandboxName, + string previewName, + string tokenName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete a preview token
+ /// Revoke the token. Requests using it are rejected immediately. + ///
+ /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task DeleteSandboxPreviewTokenAsResponseAsync( + string sandboxName, + string previewName, + string tokenName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.GetSandboxPreview.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.GetSandboxPreview.g.cs new file mode 100644 index 0000000..750b330 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.GetSandboxPreview.g.cs @@ -0,0 +1,52 @@ +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// Get a sandbox preview
+ /// Return the preview configuration, URL and status. + ///
+ /// + /// + /// + /// Default Value: false + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task GetSandboxPreviewAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + bool? showSecrets = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get a sandbox preview
+ /// Return the preview configuration, URL and status. + ///
+ /// + /// + /// + /// Default Value: false + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetSandboxPreviewAsResponseAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + bool? showSecrets = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.ListSandboxPreviewTokens.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.ListSandboxPreviewTokens.g.cs new file mode 100644 index 0000000..02879cb --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.ListSandboxPreviewTokens.g.cs @@ -0,0 +1,62 @@ +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// List preview tokens
+ /// Return the tokens of a private preview in the paginated list format, including expired tokens until they are removed. cursor and limit are accepted but not applied yet; all tokens fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied. + ///
+ /// + /// + /// + /// Example: eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ + /// + /// + /// Default Value: 20
+ /// Example: 20 + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task ListSandboxPreviewTokensAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + string? cursor = default, + int? limit = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List preview tokens
+ /// Return the tokens of a private preview in the paginated list format, including expired tokens until they are removed. cursor and limit are accepted but not applied yet; all tokens fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied. + ///
+ /// + /// + /// + /// Example: eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ + /// + /// + /// Default Value: 20
+ /// Example: 20 + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ListSandboxPreviewTokensAsResponseAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + string? cursor = default, + int? limit = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.ListSandboxPreviews.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.ListSandboxPreviews.g.cs new file mode 100644 index 0000000..127e53a --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.ListSandboxPreviews.g.cs @@ -0,0 +1,58 @@ +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// List sandbox previews
+ /// Return the previews of the sandbox in the paginated list format. cursor and limit are accepted but not applied yet; all previews fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied. + ///
+ /// + /// + /// + /// Example: eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ + /// + /// + /// Default Value: 20
+ /// Example: 20 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task ListSandboxPreviewsAsync( + string sandboxName, + string? teamId = default, + string? xTeamId = default, + string? cursor = default, + int? limit = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List sandbox previews
+ /// Return the previews of the sandbox in the paginated list format. cursor and limit are accepted but not applied yet; all previews fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied. + ///
+ /// + /// + /// + /// Example: eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ + /// + /// + /// Default Value: 20
+ /// Example: 20 + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ListSandboxPreviewsAsResponseAsync( + string sandboxName, + string? teamId = default, + string? xTeamId = default, + string? cursor = default, + int? limit = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.UpdateSandboxPreview.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.UpdateSandboxPreview.g.cs new file mode 100644 index 0000000..05c3daa --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.UpdateSandboxPreview.g.cs @@ -0,0 +1,93 @@ +#nullable enable + +namespace Baseten +{ + public partial interface IPreviewsClient + { + /// + /// Update a sandbox preview
+ /// Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400. + ///
+ /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task UpdateSandboxPreviewAsync( + string sandboxName, + string previewName, + + global::Baseten.UpdateSandboxPreviewRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update a sandbox preview
+ /// Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400. + ///
+ /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> UpdateSandboxPreviewAsResponseAsync( + string sandboxName, + string previewName, + + global::Baseten.UpdateSandboxPreviewRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update a sandbox preview
+ /// Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400. + ///
+ /// + /// + /// + /// + /// + /// Whether the URL is reachable without a preview token. Defaults to false.
+ /// Default Value: false
+ /// Example: true + /// + /// + /// Headers added to every response served by the preview, for example CORS headers. + /// + /// + /// Headers added to every request forwarded to the sandbox, for example an Authorization header expected by the application. Responses return each name with the value "****", except a GET with show_secrets=true by a workspace administrator. Sending "****" back as a value returns 400. A PATCH replaces the whole set.
+ /// Example: {"Authorization":"Bearer app-internal-token"} + /// + /// + /// Lifetime counted from the request, using seconds, minutes, hours or composite durations such as 1h30m. Whole days are also supported, for example 7d; days cannot be combined with other units. The preview is deleted when it elapses.
+ /// Example: 24h + /// + /// + /// Time at which the preview is deleted. Must be in the future.
+ /// Example: 2026-10-19T12:00:00Z + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task UpdateSandboxPreviewAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + bool? @public = default, + global::System.Collections.Generic.Dictionary? responseHeaders = default, + global::System.Collections.Generic.Dictionary? requestHeaders = default, + string? ttl = default, + global::System.DateTime? expiresAt = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.IPreviewsClient.g.cs b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.g.cs new file mode 100644 index 0000000..7936ee3 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.IPreviewsClient.g.cs @@ -0,0 +1,48 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// 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. + ///
+ public partial interface IPreviewsClient : global::System.IDisposable + { + /// + /// The HttpClient instance. + /// + public global::System.Net.Http.HttpClient HttpClient { get; } + + /// + /// The base URL for the API. + /// + public System.Uri? BaseUri { get; } + + /// + /// The authorizations to use for the requests. + /// + public global::System.Collections.Generic.List Authorizations { get; } + + /// + /// Gets or sets a value indicating whether the response content should be read as a string. + /// True by default in debug builds, false otherwise. + /// When false, successful responses are deserialized directly from the response stream for better performance. + /// Error responses are always read as strings regardless of this setting, + /// ensuring is populated. + /// + public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Baseten.AutoSDKClientOptions Options { get; } + + + /// + /// + /// + global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } + + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.JsonConverters.CreateSandboxPreviewRequestV1.g.cs b/src/libs/Baseten/Generated/Baseten.JsonConverters.CreateSandboxPreviewRequestV1.g.cs new file mode 100644 index 0000000..9fa1544 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.JsonConverters.CreateSandboxPreviewRequestV1.g.cs @@ -0,0 +1,108 @@ +#nullable enable +#pragma warning disable CS0618 // Type or member is obsolete + +namespace Baseten.JsonConverters +{ + /// + public class CreateSandboxPreviewRequestV1JsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Baseten.CreateSandboxPreviewRequestV1 Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); + var __rawJson = __jsonDocument.RootElement.GetRawText(); + + global::Baseten.SandboxPreviewConfigurationV1? configuration = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.SandboxPreviewConfigurationV1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.SandboxPreviewConfigurationV1).Name}"); + configuration = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + + global::Baseten.CreateSandboxPreviewRequestV1Variant2? createSandboxPreviewRequestV1Variant2 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2).Name}"); + createSandboxPreviewRequestV1Variant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + var __value = new global::Baseten.CreateSandboxPreviewRequestV1( + configuration, + + createSandboxPreviewRequestV1Variant2 + ); + + return __value; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Baseten.CreateSandboxPreviewRequestV1 value, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); + if (value.IsConfiguration) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.SandboxPreviewConfigurationV1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.SandboxPreviewConfigurationV1).Name}"); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.PickConfiguration(), typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } + } + if (value.IsCreateSandboxPreviewRequestV1Variant2) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2).Name}"); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.PickCreateSandboxPreviewRequestV1Variant2(), typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } + } + writer.WriteEndObject(); + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewStatusV1.g.cs b/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewStatusV1.g.cs new file mode 100644 index 0000000..3857088 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewStatusV1.g.cs @@ -0,0 +1,53 @@ +#nullable enable + +namespace Baseten.JsonConverters +{ + /// + public sealed class SandboxPreviewStatusV1JsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Baseten.SandboxPreviewStatusV1 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::Baseten.SandboxPreviewStatusV1Extensions.ToEnum(stringValue) ?? default; + } + + break; + } + case global::System.Text.Json.JsonTokenType.Number: + { + var numValue = reader.GetInt32(); + return (global::Baseten.SandboxPreviewStatusV1)numValue; + } + case global::System.Text.Json.JsonTokenType.Null: + { + return default(global::Baseten.SandboxPreviewStatusV1); + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(reader)); + } + + return default; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Baseten.SandboxPreviewStatusV1 value, + global::System.Text.Json.JsonSerializerOptions options) + { + writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); + + writer.WriteStringValue(global::Baseten.SandboxPreviewStatusV1Extensions.ToValueString(value)); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewStatusV1Nullable.g.cs b/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewStatusV1Nullable.g.cs new file mode 100644 index 0000000..c8c60dc --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewStatusV1Nullable.g.cs @@ -0,0 +1,60 @@ +#nullable enable + +namespace Baseten.JsonConverters +{ + /// + public sealed class SandboxPreviewStatusV1NullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Baseten.SandboxPreviewStatusV1? 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::Baseten.SandboxPreviewStatusV1Extensions.ToEnum(stringValue); + } + + break; + } + case global::System.Text.Json.JsonTokenType.Number: + { + var numValue = reader.GetInt32(); + return (global::Baseten.SandboxPreviewStatusV1)numValue; + } + case global::System.Text.Json.JsonTokenType.Null: + { + return default(global::Baseten.SandboxPreviewStatusV1?); + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(reader)); + } + + return default; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Baseten.SandboxPreviewStatusV1? value, + global::System.Text.Json.JsonSerializerOptions options) + { + writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); + + if (value == null) + { + writer.WriteNullValue(); + } + else + { + writer.WriteStringValue(global::Baseten.SandboxPreviewStatusV1Extensions.ToValueString(value.Value)); + } + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewV1.g.cs b/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewV1.g.cs new file mode 100644 index 0000000..f02701d --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.JsonConverters.SandboxPreviewV1.g.cs @@ -0,0 +1,108 @@ +#nullable enable +#pragma warning disable CS0618 // Type or member is obsolete + +namespace Baseten.JsonConverters +{ + /// + public class SandboxPreviewV1JsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Baseten.SandboxPreviewV1 Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); + var __rawJson = __jsonDocument.RootElement.GetRawText(); + + global::Baseten.SandboxPreviewConfigurationV1? configuration = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.SandboxPreviewConfigurationV1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.SandboxPreviewConfigurationV1).Name}"); + configuration = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + + global::Baseten.SandboxPreviewV1Variant2? sandboxPreviewV1Variant2 = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.SandboxPreviewV1Variant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.SandboxPreviewV1Variant2).Name}"); + sandboxPreviewV1Variant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + var __value = new global::Baseten.SandboxPreviewV1( + configuration, + + sandboxPreviewV1Variant2 + ); + + return __value; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Baseten.SandboxPreviewV1 value, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); + if (value.IsConfiguration) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.SandboxPreviewConfigurationV1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.SandboxPreviewConfigurationV1).Name}"); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.PickConfiguration(), typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } + } + if (value.IsSandboxPreviewV1Variant2) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.SandboxPreviewV1Variant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.SandboxPreviewV1Variant2).Name}"); + var __element1 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.PickSandboxPreviewV1Variant2(), typeInfo); + if (__element1.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element1.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } + } + writer.WriteEndObject(); + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.JsonConverters.UpdateSandboxPreviewRequestV1.g.cs b/src/libs/Baseten/Generated/Baseten.JsonConverters.UpdateSandboxPreviewRequestV1.g.cs new file mode 100644 index 0000000..b81472d --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.JsonConverters.UpdateSandboxPreviewRequestV1.g.cs @@ -0,0 +1,74 @@ +#nullable enable +#pragma warning disable CS0618 // Type or member is obsolete + +namespace Baseten.JsonConverters +{ + /// + public class UpdateSandboxPreviewRequestV1JsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Baseten.UpdateSandboxPreviewRequestV1 Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); + var __rawJson = __jsonDocument.RootElement.GetRawText(); + + global::Baseten.SandboxPreviewConfigurationV1? configuration = default; + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.SandboxPreviewConfigurationV1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.SandboxPreviewConfigurationV1).Name}"); + configuration = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + var __value = new global::Baseten.UpdateSandboxPreviewRequestV1( + configuration + ); + + return __value; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Baseten.UpdateSandboxPreviewRequestV1 value, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + + writer.WriteStartObject(); + var __writtenPropertyNames = new global::System.Collections.Generic.HashSet(global::System.StringComparer.Ordinal); + if (value.IsConfiguration) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Baseten.SandboxPreviewConfigurationV1), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Baseten.SandboxPreviewConfigurationV1).Name}"); + var __element0 = global::System.Text.Json.JsonSerializer.SerializeToElement(value.PickConfiguration(), typeInfo); + if (__element0.ValueKind != global::System.Text.Json.JsonValueKind.Object) + { + throw new global::System.Text.Json.JsonException("AllOf values must serialize as JSON objects."); + } + + foreach (var __property in __element0.EnumerateObject()) + { + if (__writtenPropertyNames.Add(__property.Name)) + { + __property.WriteTo(writer); + } + } + } + writer.WriteEndObject(); + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.JsonSerializerContext.g.cs b/src/libs/Baseten/Generated/Baseten.JsonSerializerContext.g.cs index a6289cf..22ece70 100644 --- a/src/libs/Baseten/Generated/Baseten.JsonSerializerContext.g.cs +++ b/src/libs/Baseten/Generated/Baseten.JsonSerializerContext.g.cs @@ -828,6 +828,19 @@ internal sealed partial class SourceGenerationContextChunk0 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.ListSandboxLibraryImagesResponseV1))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CleanupSandboxImagesResponseV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewStatusV1), TypeInfoPropertyName = "SandboxPreviewStatusV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewConfigurationV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CreateSandboxPreviewRequestV1), TypeInfoPropertyName = "CreateSandboxPreviewRequestV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.UpdateSandboxPreviewRequestV1), TypeInfoPropertyName = "UpdateSandboxPreviewRequestV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewV1), TypeInfoPropertyName = "SandboxPreviewV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewV1Variant2))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.ListSandboxPreviewsResponseV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CreateSandboxPreviewTokenRequestV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewTokenV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.ListSandboxPreviewTokensResponseV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(bool?))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(int?))] @@ -942,6 +955,10 @@ internal sealed partial class SourceGenerationContextChunk0 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxV1?), TypeInfoPropertyName = "NullableSandboxV12")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxStatusV1?), TypeInfoPropertyName = "NullableSandboxStatusV12")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxImageStatusV1?), TypeInfoPropertyName = "NullableSandboxImageStatusV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewStatusV1?), TypeInfoPropertyName = "NullableSandboxPreviewStatusV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CreateSandboxPreviewRequestV1?), TypeInfoPropertyName = "NullableCreateSandboxPreviewRequestV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.UpdateSandboxPreviewRequestV1?), TypeInfoPropertyName = "NullableUpdateSandboxPreviewRequestV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewV1?), TypeInfoPropertyName = "NullableSandboxPreviewV12")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] @@ -1002,6 +1019,16 @@ internal sealed partial class SourceGenerationContextChunk0 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + internal sealed partial class SourceGenerationContextChunk1 : global::System.Text.Json.Serialization.JsonSerializerContext + { + } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonSourceGenerationOptions( + DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull + )] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] @@ -1019,16 +1046,6 @@ internal sealed partial class SourceGenerationContextChunk0 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] - internal sealed partial class SourceGenerationContextChunk1 : global::System.Text.Json.Serialization.JsonSerializerContext - { - } - - /// - /// - /// - [global::System.Text.Json.Serialization.JsonSourceGenerationOptions( - DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull - )] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] @@ -1074,6 +1091,8 @@ internal sealed partial class SourceGenerationContextChunk1 : global::System.Tex [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] internal sealed partial class SourceGenerationContextChunk2 : global::System.Text.Json.Serialization.JsonSerializerContext { @@ -1129,6 +1148,9 @@ internal static void AddConverters(global::System.Text.Json.JsonSerializerOption options.Converters.Add(new global::Baseten.JsonConverters.TargetVariant1JsonConverter()); options.Converters.Add(new global::Baseten.JsonConverters.SandboxExpirationPolicyV1JsonConverter()); options.Converters.Add(new global::Baseten.JsonConverters.SandboxV1JsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.CreateSandboxPreviewRequestV1JsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.UpdateSandboxPreviewRequestV1JsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.SandboxPreviewV1JsonConverter()); options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); @@ -1539,7 +1561,11 @@ public override bool CanConvert(global::System.Type typeToConvert) || typeToConvert == typeof(global::Baseten.SandboxImageStatusV1) - || typeToConvert == typeof(global::Baseten.SandboxImageStatusV1?); + || typeToConvert == typeof(global::Baseten.SandboxImageStatusV1?) + + || typeToConvert == typeof(global::Baseten.SandboxPreviewStatusV1) + + || typeToConvert == typeof(global::Baseten.SandboxPreviewStatusV1?); } public override global::System.Text.Json.Serialization.JsonConverter CreateConverter( @@ -2465,6 +2491,16 @@ public override bool CanConvert(global::System.Type typeToConvert) { return new global::Baseten.JsonConverters.SandboxImageStatusV1NullableJsonConverter(); } + + if (typeToConvert == typeof(global::Baseten.SandboxPreviewStatusV1)) + { + return new global::Baseten.JsonConverters.SandboxPreviewStatusV1JsonConverter(); + } + + if (typeToConvert == typeof(global::Baseten.SandboxPreviewStatusV1?)) + { + return new global::Baseten.JsonConverters.SandboxPreviewStatusV1NullableJsonConverter(); + } throw new global::System.NotSupportedException($"No generated enum converter is registered for '{typeToConvert}'."); } } diff --git a/src/libs/Baseten/Generated/Baseten.JsonSerializerContextTypes.g.cs b/src/libs/Baseten/Generated/Baseten.JsonSerializerContextTypes.g.cs index 3a0a8d6..c968e30 100644 --- a/src/libs/Baseten/Generated/Baseten.JsonSerializerContextTypes.g.cs +++ b/src/libs/Baseten/Generated/Baseten.JsonSerializerContextTypes.g.cs @@ -3257,7 +3257,59 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::System.Collections.Generic.IList? Type806 { get; set; } + public global::Baseten.SandboxPreviewStatusV1? Type806 { get; set; } + /// + /// + /// + public global::Baseten.SandboxPreviewConfigurationV1? Type807 { get; set; } + /// + /// + /// + public global::Baseten.CreateSandboxPreviewRequestV1? Type808 { get; set; } + /// + /// + /// + public global::Baseten.CreateSandboxPreviewRequestV1Variant2? Type809 { get; set; } + /// + /// + /// + public global::Baseten.UpdateSandboxPreviewRequestV1? Type810 { get; set; } + /// + /// + /// + public global::Baseten.SandboxPreviewV1? Type811 { get; set; } + /// + /// + /// + public global::Baseten.SandboxPreviewV1Variant2? Type812 { get; set; } + /// + /// + /// + public global::Baseten.ListSandboxPreviewsResponseV1? Type813 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.IList? Type814 { get; set; } + /// + /// + /// + public global::Baseten.CreateSandboxPreviewTokenRequestV1? Type815 { get; set; } + /// + /// + /// + public global::Baseten.SandboxPreviewTokenV1? Type816 { get; set; } + /// + /// + /// + public global::Baseten.ListSandboxPreviewTokensResponseV1? Type817 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.IList? Type818 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.IList? Type819 { get; set; } /// /// @@ -3754,6 +3806,14 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::System.Collections.Generic.List? ListType123 { get; set; } + public global::System.Collections.Generic.List? ListType123 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.List? ListType124 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.List? ListType125 { get; set; } } } \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1.Json.g.cs new file mode 100644 index 0000000..a143712 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public readonly partial struct CreateSandboxPreviewRequestV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.CreateSandboxPreviewRequestV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.CreateSandboxPreviewRequestV1), + jsonSerializerContext) as global::Baseten.CreateSandboxPreviewRequestV1?; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.CreateSandboxPreviewRequestV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.CreateSandboxPreviewRequestV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.CreateSandboxPreviewRequestV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.CreateSandboxPreviewRequestV1?; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1.g.cs new file mode 100644 index 0000000..f2fa77a --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1.g.cs @@ -0,0 +1,295 @@ +#pragma warning disable CS0618 // Type or member is obsolete + +#nullable enable + +namespace Baseten +{ + /// + /// Preview to create. Only port is required. + /// + public readonly partial struct CreateSandboxPreviewRequestV1 : global::System.IEquatable + { + /// + /// Mutable preview configuration. ttl and expires_at are mutually exclusive; supplying both returns 400. + /// +#if NET6_0_OR_GREATER + public global::Baseten.SandboxPreviewConfigurationV1? Configuration { get; init; } +#else + public global::Baseten.SandboxPreviewConfigurationV1? Configuration { get; } +#endif + + /// + /// + /// +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Configuration))] +#endif + public bool IsConfiguration => Configuration != null; + + /// + /// + /// + public bool TryPickConfiguration( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Baseten.SandboxPreviewConfigurationV1? value) + { + value = Configuration; + return IsConfiguration; + } + + /// + /// + /// + public global::Baseten.SandboxPreviewConfigurationV1 PickConfiguration() => Configuration is { } value + ? value + : throw new global::System.InvalidOperationException($"Expected union variant 'Configuration' but the value was {ToString()}."); + + /// + /// + /// +#if NET6_0_OR_GREATER + public global::Baseten.CreateSandboxPreviewRequestV1Variant2? CreateSandboxPreviewRequestV1Variant2 { get; init; } +#else + public global::Baseten.CreateSandboxPreviewRequestV1Variant2? CreateSandboxPreviewRequestV1Variant2 { get; } +#endif + + /// + /// + /// +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(CreateSandboxPreviewRequestV1Variant2))] +#endif + public bool IsCreateSandboxPreviewRequestV1Variant2 => CreateSandboxPreviewRequestV1Variant2 != null; + + /// + /// + /// + public bool TryPickCreateSandboxPreviewRequestV1Variant2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Baseten.CreateSandboxPreviewRequestV1Variant2? value) + { + value = CreateSandboxPreviewRequestV1Variant2; + return IsCreateSandboxPreviewRequestV1Variant2; + } + + /// + /// + /// + public global::Baseten.CreateSandboxPreviewRequestV1Variant2 PickCreateSandboxPreviewRequestV1Variant2() => CreateSandboxPreviewRequestV1Variant2 is { } value + ? value + : throw new global::System.InvalidOperationException($"Expected union variant 'CreateSandboxPreviewRequestV1Variant2' but the value was {ToString()}."); + /// + /// + /// + public static implicit operator CreateSandboxPreviewRequestV1(global::Baseten.SandboxPreviewConfigurationV1 value) => new CreateSandboxPreviewRequestV1((global::Baseten.SandboxPreviewConfigurationV1?)value); + + /// + /// + /// + public static implicit operator global::Baseten.SandboxPreviewConfigurationV1?(CreateSandboxPreviewRequestV1 @this) => @this.Configuration; + + /// + /// + /// + public CreateSandboxPreviewRequestV1(global::Baseten.SandboxPreviewConfigurationV1? value) + { + Configuration = value; + } + + /// + /// + /// + public static CreateSandboxPreviewRequestV1 FromConfiguration(global::Baseten.SandboxPreviewConfigurationV1? value) => new CreateSandboxPreviewRequestV1(value); + + /// + /// + /// + public static implicit operator CreateSandboxPreviewRequestV1(global::Baseten.CreateSandboxPreviewRequestV1Variant2 value) => new CreateSandboxPreviewRequestV1((global::Baseten.CreateSandboxPreviewRequestV1Variant2?)value); + + /// + /// + /// + public static implicit operator global::Baseten.CreateSandboxPreviewRequestV1Variant2?(CreateSandboxPreviewRequestV1 @this) => @this.CreateSandboxPreviewRequestV1Variant2; + + /// + /// + /// + public CreateSandboxPreviewRequestV1(global::Baseten.CreateSandboxPreviewRequestV1Variant2? value) + { + CreateSandboxPreviewRequestV1Variant2 = value; + } + + /// + /// + /// + public static CreateSandboxPreviewRequestV1 FromCreateSandboxPreviewRequestV1Variant2(global::Baseten.CreateSandboxPreviewRequestV1Variant2? value) => new CreateSandboxPreviewRequestV1(value); + + /// + /// + /// + public CreateSandboxPreviewRequestV1( + global::Baseten.SandboxPreviewConfigurationV1? configuration, + global::Baseten.CreateSandboxPreviewRequestV1Variant2? createSandboxPreviewRequestV1Variant2 + ) + { + Configuration = configuration; + CreateSandboxPreviewRequestV1Variant2 = createSandboxPreviewRequestV1Variant2; + } + + /// + /// + /// + public object? Object => + CreateSandboxPreviewRequestV1Variant2 as object ?? + Configuration as object + ; + + /// + /// + /// + public override string? ToString() => + Configuration?.ToString() ?? + CreateSandboxPreviewRequestV1Variant2?.ToString() + ; + + /// + /// + /// + public bool Validate() + { + return IsConfiguration && IsCreateSandboxPreviewRequestV1Variant2; + } + + /// + /// + /// + public TResult? Match( + global::System.Func? configuration = null, + global::System.Func? createSandboxPreviewRequestV1Variant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0 && configuration != null) + { + return configuration(__value0); + } + else if (CreateSandboxPreviewRequestV1Variant2 is { } __value1 && createSandboxPreviewRequestV1Variant2 != null) + { + return createSandboxPreviewRequestV1Variant2(__value1); + } + + return default(TResult); + } + + /// + /// + /// + public void Match( + global::System.Action? configuration = null, + + global::System.Action? createSandboxPreviewRequestV1Variant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0) + { + configuration?.Invoke(__value0); + } + else if (CreateSandboxPreviewRequestV1Variant2 is { } __value1) + { + createSandboxPreviewRequestV1Variant2?.Invoke(__value1); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? configuration = null, + global::System.Action? createSandboxPreviewRequestV1Variant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0) + { + configuration?.Invoke(__value0); + } + else if (CreateSandboxPreviewRequestV1Variant2 is { } __value1) + { + createSandboxPreviewRequestV1Variant2?.Invoke(__value1); + } + } + + /// + /// + /// + public override int GetHashCode() + { + var fields = new object?[] + { + Configuration, + typeof(global::Baseten.SandboxPreviewConfigurationV1), + CreateSandboxPreviewRequestV1Variant2, + typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2), + }; + const int offset = unchecked((int)2166136261); + const int prime = 16777619; + static int HashCodeAggregator(int hashCode, object? value) => value == null + ? (hashCode ^ 0) * prime + : (hashCode ^ value.GetHashCode()) * prime; + + return global::System.Linq.Enumerable.Aggregate(fields, offset, HashCodeAggregator); + } + + /// + /// + /// + public bool Equals(CreateSandboxPreviewRequestV1 other) + { + return + global::System.Collections.Generic.EqualityComparer.Default.Equals(Configuration, other.Configuration) && + global::System.Collections.Generic.EqualityComparer.Default.Equals(CreateSandboxPreviewRequestV1Variant2, other.CreateSandboxPreviewRequestV1Variant2) + ; + } + + /// + /// + /// + public static bool operator ==(CreateSandboxPreviewRequestV1 obj1, CreateSandboxPreviewRequestV1 obj2) + { + return global::System.Collections.Generic.EqualityComparer.Default.Equals(obj1, obj2); + } + + /// + /// + /// + public static bool operator !=(CreateSandboxPreviewRequestV1 obj1, CreateSandboxPreviewRequestV1 obj2) + { + return !(obj1 == obj2); + } + + /// + /// + /// + public override bool Equals(object? obj) + { + return obj is CreateSandboxPreviewRequestV1 o && Equals(o); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1Variant2.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1Variant2.Json.g.cs new file mode 100644 index 0000000..5876174 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1Variant2.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public sealed partial class CreateSandboxPreviewRequestV1Variant2 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.CreateSandboxPreviewRequestV1Variant2? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2), + jsonSerializerContext) as global::Baseten.CreateSandboxPreviewRequestV1Variant2; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.CreateSandboxPreviewRequestV1Variant2? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.CreateSandboxPreviewRequestV1Variant2? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.CreateSandboxPreviewRequestV1Variant2; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1Variant2.g.cs b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1Variant2.g.cs new file mode 100644 index 0000000..a2eafee --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewRequestV1Variant2.g.cs @@ -0,0 +1,75 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// + /// + public sealed partial class CreateSandboxPreviewRequestV1Variant2 + { + /// + /// When true, return the existing preview with this name instead of failing with a conflict. Without name, the name is public-<port> or private-<port>, so the same port and visibility return the same preview. Existing configuration is preserved. Defaults to false when omitted. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("create_if_not_exists")] + public bool? CreateIfNotExists { get; set; } + + /// + /// Preview name, unique within the sandbox. When omitted, generated from the sandbox name and port, or public-<port> or private-<port> when create_if_not_exists is true.
+ /// Example: web + ///
+ /// web + [global::System.Text.Json.Serialization.JsonPropertyName("name")] + public string? Name { get; set; } + + /// + /// Sandbox port to expose.
+ /// Example: 3000 + ///
+ /// 3000 + [global::System.Text.Json.Serialization.JsonPropertyName("port")] + [global::System.Text.Json.Serialization.JsonRequired] + public required int Port { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Sandbox port to expose.
+ /// Example: 3000 + /// + /// + /// When true, return the existing preview with this name instead of failing with a conflict. Without name, the name is public-<port> or private-<port>, so the same port and visibility return the same preview. Existing configuration is preserved. Defaults to false when omitted. + /// + /// + /// Preview name, unique within the sandbox. When omitted, generated from the sandbox name and port, or public-<port> or private-<port> when create_if_not_exists is true.
+ /// Example: web + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public CreateSandboxPreviewRequestV1Variant2( + int port, + bool? createIfNotExists, + string? name) + { + this.CreateIfNotExists = createIfNotExists; + this.Name = name; + this.Port = port; + } + + /// + /// Initializes a new instance of the class. + /// + public CreateSandboxPreviewRequestV1Variant2() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewTokenRequestV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewTokenRequestV1.Json.g.cs new file mode 100644 index 0000000..c05f876 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewTokenRequestV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public sealed partial class CreateSandboxPreviewTokenRequestV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.CreateSandboxPreviewTokenRequestV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.CreateSandboxPreviewTokenRequestV1), + jsonSerializerContext) as global::Baseten.CreateSandboxPreviewTokenRequestV1; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.CreateSandboxPreviewTokenRequestV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.CreateSandboxPreviewTokenRequestV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.CreateSandboxPreviewTokenRequestV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.CreateSandboxPreviewTokenRequestV1; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewTokenRequestV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewTokenRequestV1.g.cs new file mode 100644 index 0000000..132ffa7 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.CreateSandboxPreviewTokenRequestV1.g.cs @@ -0,0 +1,61 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// + /// + public sealed partial class CreateSandboxPreviewTokenRequestV1 + { + /// + /// When true, return an existing unexpired token of this preview that stays valid at least until expires_at instead of creating a new one. Defaults to false when omitted. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("create_if_not_exists")] + public bool? CreateIfNotExists { get; set; } + + /// + /// Time at which the token stops working. Must be in the future.
+ /// Example: 2026-10-13T12:00:00Z + ///
+ /// 2026-10-13T12:00:00Z + [global::System.Text.Json.Serialization.JsonPropertyName("expires_at")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::System.DateTime ExpiresAt { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Time at which the token stops working. Must be in the future.
+ /// Example: 2026-10-13T12:00:00Z + /// + /// + /// When true, return an existing unexpired token of this preview that stays valid at least until expires_at instead of creating a new one. Defaults to false when omitted. + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public CreateSandboxPreviewTokenRequestV1( + global::System.DateTime expiresAt, + bool? createIfNotExists) + { + this.CreateIfNotExists = createIfNotExists; + this.ExpiresAt = expiresAt; + } + + /// + /// Initializes a new instance of the class. + /// + public CreateSandboxPreviewTokenRequestV1() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewTokensResponseV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewTokensResponseV1.Json.g.cs new file mode 100644 index 0000000..d32a6e6 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewTokensResponseV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public sealed partial class ListSandboxPreviewTokensResponseV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.ListSandboxPreviewTokensResponseV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.ListSandboxPreviewTokensResponseV1), + jsonSerializerContext) as global::Baseten.ListSandboxPreviewTokensResponseV1; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.ListSandboxPreviewTokensResponseV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.ListSandboxPreviewTokensResponseV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.ListSandboxPreviewTokensResponseV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.ListSandboxPreviewTokensResponseV1; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewTokensResponseV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewTokensResponseV1.g.cs new file mode 100644 index 0000000..6178f7c --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewTokensResponseV1.g.cs @@ -0,0 +1,62 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// One page of tokens of a preview. + /// + public sealed partial class ListSandboxPreviewTokensResponseV1 + { + /// + /// Resources on this page. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("items")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::System.Collections.Generic.IList Items { get; set; } + + /// + /// Cursor pagination information. The cursor is present only when another page is available.
+ /// Example: {"has_more":true,"cursor":"eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ"} + ///
+ /// {"has_more":true,"cursor":"eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ"} + [global::System.Text.Json.Serialization.JsonPropertyName("pagination")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::Baseten.SandboxApiPaginationV1 Pagination { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Resources on this page. + /// + /// + /// Cursor pagination information. The cursor is present only when another page is available.
+ /// Example: {"has_more":true,"cursor":"eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ"} + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public ListSandboxPreviewTokensResponseV1( + global::System.Collections.Generic.IList items, + global::Baseten.SandboxApiPaginationV1 pagination) + { + this.Items = items ?? throw new global::System.ArgumentNullException(nameof(items)); + this.Pagination = pagination ?? throw new global::System.ArgumentNullException(nameof(pagination)); + } + + /// + /// Initializes a new instance of the class. + /// + public ListSandboxPreviewTokensResponseV1() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewsResponseV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewsResponseV1.Json.g.cs new file mode 100644 index 0000000..997c2b6 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewsResponseV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public sealed partial class ListSandboxPreviewsResponseV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.ListSandboxPreviewsResponseV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.ListSandboxPreviewsResponseV1), + jsonSerializerContext) as global::Baseten.ListSandboxPreviewsResponseV1; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.ListSandboxPreviewsResponseV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.ListSandboxPreviewsResponseV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.ListSandboxPreviewsResponseV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.ListSandboxPreviewsResponseV1; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewsResponseV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewsResponseV1.g.cs new file mode 100644 index 0000000..5cbfc87 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.ListSandboxPreviewsResponseV1.g.cs @@ -0,0 +1,62 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// One page of previews of a sandbox. + /// + public sealed partial class ListSandboxPreviewsResponseV1 + { + /// + /// Resources on this page. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("items")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::System.Collections.Generic.IList Items { get; set; } + + /// + /// Cursor pagination information. The cursor is present only when another page is available.
+ /// Example: {"has_more":true,"cursor":"eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ"} + ///
+ /// {"has_more":true,"cursor":"eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ"} + [global::System.Text.Json.Serialization.JsonPropertyName("pagination")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::Baseten.SandboxApiPaginationV1 Pagination { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Resources on this page. + /// + /// + /// Cursor pagination information. The cursor is present only when another page is available.
+ /// Example: {"has_more":true,"cursor":"eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ"} + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public ListSandboxPreviewsResponseV1( + global::System.Collections.Generic.IList items, + global::Baseten.SandboxApiPaginationV1 pagination) + { + this.Items = items ?? throw new global::System.ArgumentNullException(nameof(items)); + this.Pagination = pagination ?? throw new global::System.ArgumentNullException(nameof(pagination)); + } + + /// + /// Initializes a new instance of the class. + /// + public ListSandboxPreviewsResponseV1() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewConfigurationV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewConfigurationV1.Json.g.cs new file mode 100644 index 0000000..9382511 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewConfigurationV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public sealed partial class SandboxPreviewConfigurationV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewConfigurationV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.SandboxPreviewConfigurationV1), + jsonSerializerContext) as global::Baseten.SandboxPreviewConfigurationV1; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewConfigurationV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.SandboxPreviewConfigurationV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.SandboxPreviewConfigurationV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.SandboxPreviewConfigurationV1; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewConfigurationV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewConfigurationV1.g.cs new file mode 100644 index 0000000..e1971e2 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewConfigurationV1.g.cs @@ -0,0 +1,104 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// Mutable preview configuration. ttl and expires_at are mutually exclusive; supplying both returns 400. + /// + public sealed partial class SandboxPreviewConfigurationV1 + { + /// + /// Whether the URL is reachable without a preview token. Defaults to false.
+ /// Default Value: false
+ /// Example: true + ///
+ /// true + [global::System.Text.Json.Serialization.JsonPropertyName("public")] + public bool? Public { get; set; } + + /// + /// Headers added to every response served by the preview, for example CORS headers. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("response_headers")] + public global::System.Collections.Generic.Dictionary? ResponseHeaders { get; set; } + + /// + /// Headers added to every request forwarded to the sandbox, for example an Authorization header expected by the application. Responses return each name with the value "****", except a GET with show_secrets=true by a workspace administrator. Sending "****" back as a value returns 400. A PATCH replaces the whole set.
+ /// Example: {"Authorization":"Bearer app-internal-token"} + ///
+ /// {"Authorization":"Bearer app-internal-token"} + [global::System.Text.Json.Serialization.JsonPropertyName("request_headers")] + public global::System.Collections.Generic.Dictionary? RequestHeaders { get; set; } + + /// + /// Lifetime counted from the request, using seconds, minutes, hours or composite durations such as 1h30m. Whole days are also supported, for example 7d; days cannot be combined with other units. The preview is deleted when it elapses.
+ /// Example: 24h + ///
+ /// 24h + [global::System.Text.Json.Serialization.JsonPropertyName("ttl")] + public string? Ttl { get; set; } + + /// + /// Time at which the preview is deleted. Must be in the future.
+ /// Example: 2026-10-19T12:00:00Z + ///
+ /// 2026-10-19T12:00:00Z + [global::System.Text.Json.Serialization.JsonPropertyName("expires_at")] + public global::System.DateTime? ExpiresAt { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Whether the URL is reachable without a preview token. Defaults to false.
+ /// Default Value: false
+ /// Example: true + /// + /// + /// Headers added to every response served by the preview, for example CORS headers. + /// + /// + /// Headers added to every request forwarded to the sandbox, for example an Authorization header expected by the application. Responses return each name with the value "****", except a GET with show_secrets=true by a workspace administrator. Sending "****" back as a value returns 400. A PATCH replaces the whole set.
+ /// Example: {"Authorization":"Bearer app-internal-token"} + /// + /// + /// Lifetime counted from the request, using seconds, minutes, hours or composite durations such as 1h30m. Whole days are also supported, for example 7d; days cannot be combined with other units. The preview is deleted when it elapses.
+ /// Example: 24h + /// + /// + /// Time at which the preview is deleted. Must be in the future.
+ /// Example: 2026-10-19T12:00:00Z + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public SandboxPreviewConfigurationV1( + bool? @public, + global::System.Collections.Generic.Dictionary? responseHeaders, + global::System.Collections.Generic.Dictionary? requestHeaders, + string? ttl, + global::System.DateTime? expiresAt) + { + this.Public = @public; + this.ResponseHeaders = responseHeaders; + this.RequestHeaders = requestHeaders; + this.Ttl = ttl; + this.ExpiresAt = expiresAt; + } + + /// + /// Initializes a new instance of the class. + /// + public SandboxPreviewConfigurationV1() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewHeadersV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewHeadersV1.Json.g.cs new file mode 100644 index 0000000..40dda40 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewHeadersV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public sealed partial class SandboxPreviewHeadersV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewHeadersV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.SandboxPreviewHeadersV1), + jsonSerializerContext) as global::Baseten.SandboxPreviewHeadersV1; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewHeadersV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.SandboxPreviewHeadersV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.SandboxPreviewHeadersV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.SandboxPreviewHeadersV1; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewHeadersV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewHeadersV1.g.cs new file mode 100644 index 0000000..f0ace91 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewHeadersV1.g.cs @@ -0,0 +1,20 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// HTTP headers as name-value pairs.
+ /// Example: {"Access-Control-Allow-Origin":"*"} + ///
+ public sealed partial class SandboxPreviewHeadersV1 + { + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewStatusV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewStatusV1.g.cs new file mode 100644 index 0000000..2a1fb4b --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewStatusV1.g.cs @@ -0,0 +1,71 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// Preview status, always uppercase.
+ /// Included only in responses
+ /// Example: DEPLOYED + ///
+ public enum SandboxPreviewStatusV1 + { + /// + /// + /// + Deleting, + /// + /// + /// + Deployed, + /// + /// + /// + Deploying, + /// + /// + /// + Failed, + /// + /// + /// + Terminated, + } + + /// + /// Enum extensions to do fast conversions without the reflection. + /// + public static class SandboxPreviewStatusV1Extensions + { + /// + /// Converts an enum to a string. + /// + public static string ToValueString(this SandboxPreviewStatusV1 value) + { + return value switch + { + SandboxPreviewStatusV1.Deleting => "DELETING", + SandboxPreviewStatusV1.Deployed => "DEPLOYED", + SandboxPreviewStatusV1.Deploying => "DEPLOYING", + SandboxPreviewStatusV1.Failed => "FAILED", + SandboxPreviewStatusV1.Terminated => "TERMINATED", + _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), + }; + } + /// + /// Converts an string to a enum. + /// + public static SandboxPreviewStatusV1? ToEnum(string value) + { + return value switch + { + "DELETING" => SandboxPreviewStatusV1.Deleting, + "DEPLOYED" => SandboxPreviewStatusV1.Deployed, + "DEPLOYING" => SandboxPreviewStatusV1.Deploying, + "FAILED" => SandboxPreviewStatusV1.Failed, + "TERMINATED" => SandboxPreviewStatusV1.Terminated, + _ => null, + }; + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewTokenV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewTokenV1.Json.g.cs new file mode 100644 index 0000000..f044471 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewTokenV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public sealed partial class SandboxPreviewTokenV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewTokenV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.SandboxPreviewTokenV1), + jsonSerializerContext) as global::Baseten.SandboxPreviewTokenV1; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewTokenV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.SandboxPreviewTokenV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.SandboxPreviewTokenV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.SandboxPreviewTokenV1; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewTokenV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewTokenV1.g.cs new file mode 100644 index 0000000..a1e7a06 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewTokenV1.g.cs @@ -0,0 +1,93 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// Access token for a private preview. + /// + public sealed partial class SandboxPreviewTokenV1 + { + /// + /// Token name, used in token_name path parameters.
+ /// Example: 7f3k2m9q1x8c4v6b0n5z + ///
+ /// 7f3k2m9q1x8c4v6b0n5z + [global::System.Text.Json.Serialization.JsonPropertyName("name")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string Name { get; set; } + + /// + /// Value to send as the bl_preview_token query parameter.
+ /// Example: 7f3k2m9q1x8c4v6b0n5z + ///
+ /// 7f3k2m9q1x8c4v6b0n5z + [global::System.Text.Json.Serialization.JsonPropertyName("token")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string Token { get; set; } + + /// + /// Example: 2026-10-13T12:00:00Z + /// + /// 2026-10-13T12:00:00Z + [global::System.Text.Json.Serialization.JsonPropertyName("expires_at")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::System.DateTime ExpiresAt { get; set; } + + /// + /// Whether expires_at has passed.
+ /// Example: false + ///
+ /// false + [global::System.Text.Json.Serialization.JsonPropertyName("expired")] + [global::System.Text.Json.Serialization.JsonRequired] + public required bool Expired { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Token name, used in token_name path parameters.
+ /// Example: 7f3k2m9q1x8c4v6b0n5z + /// + /// + /// Value to send as the bl_preview_token query parameter.
+ /// Example: 7f3k2m9q1x8c4v6b0n5z + /// + /// + /// Example: 2026-10-13T12:00:00Z + /// + /// + /// Whether expires_at has passed.
+ /// Example: false + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public SandboxPreviewTokenV1( + string name, + string token, + global::System.DateTime expiresAt, + bool expired) + { + this.Name = name ?? throw new global::System.ArgumentNullException(nameof(name)); + this.Token = token ?? throw new global::System.ArgumentNullException(nameof(token)); + this.ExpiresAt = expiresAt; + this.Expired = expired; + } + + /// + /// Initializes a new instance of the class. + /// + public SandboxPreviewTokenV1() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1.Json.g.cs new file mode 100644 index 0000000..fae5990 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public readonly partial struct SandboxPreviewV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.SandboxPreviewV1), + jsonSerializerContext) as global::Baseten.SandboxPreviewV1?; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.SandboxPreviewV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.SandboxPreviewV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.SandboxPreviewV1?; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1.g.cs new file mode 100644 index 0000000..9b71c51 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1.g.cs @@ -0,0 +1,295 @@ +#pragma warning disable CS0618 // Type or member is obsolete + +#nullable enable + +namespace Baseten +{ + /// + /// Sandbox preview with configuration and server-managed fields at the root. + /// + public readonly partial struct SandboxPreviewV1 : global::System.IEquatable + { + /// + /// Mutable preview configuration. ttl and expires_at are mutually exclusive; supplying both returns 400. + /// +#if NET6_0_OR_GREATER + public global::Baseten.SandboxPreviewConfigurationV1? Configuration { get; init; } +#else + public global::Baseten.SandboxPreviewConfigurationV1? Configuration { get; } +#endif + + /// + /// + /// +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Configuration))] +#endif + public bool IsConfiguration => Configuration != null; + + /// + /// + /// + public bool TryPickConfiguration( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Baseten.SandboxPreviewConfigurationV1? value) + { + value = Configuration; + return IsConfiguration; + } + + /// + /// + /// + public global::Baseten.SandboxPreviewConfigurationV1 PickConfiguration() => Configuration is { } value + ? value + : throw new global::System.InvalidOperationException($"Expected union variant 'Configuration' but the value was {ToString()}."); + + /// + /// + /// +#if NET6_0_OR_GREATER + public global::Baseten.SandboxPreviewV1Variant2? SandboxPreviewV1Variant2 { get; init; } +#else + public global::Baseten.SandboxPreviewV1Variant2? SandboxPreviewV1Variant2 { get; } +#endif + + /// + /// + /// +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(SandboxPreviewV1Variant2))] +#endif + public bool IsSandboxPreviewV1Variant2 => SandboxPreviewV1Variant2 != null; + + /// + /// + /// + public bool TryPickSandboxPreviewV1Variant2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Baseten.SandboxPreviewV1Variant2? value) + { + value = SandboxPreviewV1Variant2; + return IsSandboxPreviewV1Variant2; + } + + /// + /// + /// + public global::Baseten.SandboxPreviewV1Variant2 PickSandboxPreviewV1Variant2() => SandboxPreviewV1Variant2 is { } value + ? value + : throw new global::System.InvalidOperationException($"Expected union variant 'SandboxPreviewV1Variant2' but the value was {ToString()}."); + /// + /// + /// + public static implicit operator SandboxPreviewV1(global::Baseten.SandboxPreviewConfigurationV1 value) => new SandboxPreviewV1((global::Baseten.SandboxPreviewConfigurationV1?)value); + + /// + /// + /// + public static implicit operator global::Baseten.SandboxPreviewConfigurationV1?(SandboxPreviewV1 @this) => @this.Configuration; + + /// + /// + /// + public SandboxPreviewV1(global::Baseten.SandboxPreviewConfigurationV1? value) + { + Configuration = value; + } + + /// + /// + /// + public static SandboxPreviewV1 FromConfiguration(global::Baseten.SandboxPreviewConfigurationV1? value) => new SandboxPreviewV1(value); + + /// + /// + /// + public static implicit operator SandboxPreviewV1(global::Baseten.SandboxPreviewV1Variant2 value) => new SandboxPreviewV1((global::Baseten.SandboxPreviewV1Variant2?)value); + + /// + /// + /// + public static implicit operator global::Baseten.SandboxPreviewV1Variant2?(SandboxPreviewV1 @this) => @this.SandboxPreviewV1Variant2; + + /// + /// + /// + public SandboxPreviewV1(global::Baseten.SandboxPreviewV1Variant2? value) + { + SandboxPreviewV1Variant2 = value; + } + + /// + /// + /// + public static SandboxPreviewV1 FromSandboxPreviewV1Variant2(global::Baseten.SandboxPreviewV1Variant2? value) => new SandboxPreviewV1(value); + + /// + /// + /// + public SandboxPreviewV1( + global::Baseten.SandboxPreviewConfigurationV1? configuration, + global::Baseten.SandboxPreviewV1Variant2? sandboxPreviewV1Variant2 + ) + { + Configuration = configuration; + SandboxPreviewV1Variant2 = sandboxPreviewV1Variant2; + } + + /// + /// + /// + public object? Object => + SandboxPreviewV1Variant2 as object ?? + Configuration as object + ; + + /// + /// + /// + public override string? ToString() => + Configuration?.ToString() ?? + SandboxPreviewV1Variant2?.ToString() + ; + + /// + /// + /// + public bool Validate() + { + return IsConfiguration && IsSandboxPreviewV1Variant2; + } + + /// + /// + /// + public TResult? Match( + global::System.Func? configuration = null, + global::System.Func? sandboxPreviewV1Variant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0 && configuration != null) + { + return configuration(__value0); + } + else if (SandboxPreviewV1Variant2 is { } __value1 && sandboxPreviewV1Variant2 != null) + { + return sandboxPreviewV1Variant2(__value1); + } + + return default(TResult); + } + + /// + /// + /// + public void Match( + global::System.Action? configuration = null, + + global::System.Action? sandboxPreviewV1Variant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0) + { + configuration?.Invoke(__value0); + } + else if (SandboxPreviewV1Variant2 is { } __value1) + { + sandboxPreviewV1Variant2?.Invoke(__value1); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? configuration = null, + global::System.Action? sandboxPreviewV1Variant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0) + { + configuration?.Invoke(__value0); + } + else if (SandboxPreviewV1Variant2 is { } __value1) + { + sandboxPreviewV1Variant2?.Invoke(__value1); + } + } + + /// + /// + /// + public override int GetHashCode() + { + var fields = new object?[] + { + Configuration, + typeof(global::Baseten.SandboxPreviewConfigurationV1), + SandboxPreviewV1Variant2, + typeof(global::Baseten.SandboxPreviewV1Variant2), + }; + const int offset = unchecked((int)2166136261); + const int prime = 16777619; + static int HashCodeAggregator(int hashCode, object? value) => value == null + ? (hashCode ^ 0) * prime + : (hashCode ^ value.GetHashCode()) * prime; + + return global::System.Linq.Enumerable.Aggregate(fields, offset, HashCodeAggregator); + } + + /// + /// + /// + public bool Equals(SandboxPreviewV1 other) + { + return + global::System.Collections.Generic.EqualityComparer.Default.Equals(Configuration, other.Configuration) && + global::System.Collections.Generic.EqualityComparer.Default.Equals(SandboxPreviewV1Variant2, other.SandboxPreviewV1Variant2) + ; + } + + /// + /// + /// + public static bool operator ==(SandboxPreviewV1 obj1, SandboxPreviewV1 obj2) + { + return global::System.Collections.Generic.EqualityComparer.Default.Equals(obj1, obj2); + } + + /// + /// + /// + public static bool operator !=(SandboxPreviewV1 obj1, SandboxPreviewV1 obj2) + { + return !(obj1 == obj2); + } + + /// + /// + /// + public override bool Equals(object? obj) + { + return obj is SandboxPreviewV1 o && Equals(o); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1Variant2.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1Variant2.Json.g.cs new file mode 100644 index 0000000..130d81d --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1Variant2.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public sealed partial class SandboxPreviewV1Variant2 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewV1Variant2? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.SandboxPreviewV1Variant2), + jsonSerializerContext) as global::Baseten.SandboxPreviewV1Variant2; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.SandboxPreviewV1Variant2? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.SandboxPreviewV1Variant2? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.SandboxPreviewV1Variant2), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.SandboxPreviewV1Variant2; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1Variant2.g.cs b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1Variant2.g.cs new file mode 100644 index 0000000..3fa425f --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.SandboxPreviewV1Variant2.g.cs @@ -0,0 +1,176 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// + /// + public sealed partial class SandboxPreviewV1Variant2 + { + /// + /// Preview name, used in preview_name path parameters.
+ /// Included only in responses
+ /// Example: web + ///
+ /// default! + /// web + [global::System.Text.Json.Serialization.JsonPropertyName("name")] + public string Name { get; set; } = default!; + + /// + /// Exposed sandbox port.
+ /// Included only in responses
+ /// Example: 3000 + ///
+ /// default! + /// 3000 + [global::System.Text.Json.Serialization.JsonPropertyName("port")] + public int Port { get; set; } = default!; + + /// + /// HTTPS URL serving the port, including the region label. Use this exact URL. Requests to a private preview need a token.
+ /// Included only in responses
+ /// Example: https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co + ///
+ /// default! + /// https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co + [global::System.Text.Json.Serialization.JsonPropertyName("url")] + public string Url { get; set; } = default!; + + /// + /// Preview status, always uppercase.
+ /// Included only in responses
+ /// Example: DEPLOYED + ///
+ /// default! + /// DEPLOYED + [global::System.Text.Json.Serialization.JsonPropertyName("status")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Baseten.JsonConverters.SandboxPreviewStatusV1JsonConverter))] + public global::Baseten.SandboxPreviewStatusV1 Status { get; set; } = default!; + + /// + /// Region serving the preview, the sandbox's region.
+ /// Included only in responses
+ /// Example: us-pdx-1 + ///
+ /// us-pdx-1 + [global::System.Text.Json.Serialization.JsonPropertyName("region")] + public string? Region { get; set; } + + /// + /// Included only in responses
+ /// Example: 2026-10-12T12:00:00Z + ///
+ /// 2026-10-12T12:00:00Z + [global::System.Text.Json.Serialization.JsonPropertyName("created_at")] + public global::System.DateTime? CreatedAt { get; set; } + + /// + /// Included only in responses
+ /// Example: 2026-10-12T12:00:00Z + ///
+ /// 2026-10-12T12:00:00Z + [global::System.Text.Json.Serialization.JsonPropertyName("updated_at")] + public global::System.DateTime? UpdatedAt { get; set; } + + /// + /// Included only in responses
+ /// Example: sandbox-automation + ///
+ /// sandbox-automation + [global::System.Text.Json.Serialization.JsonPropertyName("created_by")] + public string? CreatedBy { get; set; } + + /// + /// Included only in responses
+ /// Example: sandbox-automation + ///
+ /// sandbox-automation + [global::System.Text.Json.Serialization.JsonPropertyName("updated_by")] + public string? UpdatedBy { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Region serving the preview, the sandbox's region.
+ /// Included only in responses
+ /// Example: us-pdx-1 + /// + /// + /// Included only in responses
+ /// Example: 2026-10-12T12:00:00Z + /// + /// + /// Included only in responses
+ /// Example: 2026-10-12T12:00:00Z + /// + /// + /// Included only in responses
+ /// Example: sandbox-automation + /// + /// + /// Included only in responses
+ /// Example: sandbox-automation + /// + /// + /// Preview name, used in preview_name path parameters.
+ /// Included only in responses
+ /// Example: web + /// + /// + /// Exposed sandbox port.
+ /// Included only in responses
+ /// Example: 3000 + /// + /// + /// HTTPS URL serving the port, including the region label. Use this exact URL. Requests to a private preview need a token.
+ /// Included only in responses
+ /// Example: https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co + /// + /// + /// Preview status, always uppercase.
+ /// Included only in responses
+ /// Example: DEPLOYED + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public SandboxPreviewV1Variant2( + string? region, + global::System.DateTime? createdAt, + global::System.DateTime? updatedAt, + string? createdBy, + string? updatedBy, + string name = default!, + int port = default!, + string url = default!, + global::Baseten.SandboxPreviewStatusV1 status = default!) + { + this.Name = name; + this.Port = port; + this.Url = url; + this.Status = status; + this.Region = region; + this.CreatedAt = createdAt; + this.UpdatedAt = updatedAt; + this.CreatedBy = createdBy; + this.UpdatedBy = updatedBy; + } + + /// + /// Initializes a new instance of the class. + /// + public SandboxPreviewV1Variant2() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.Models.TrainingJobV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.TrainingJobV1.g.cs index 94573e6..8c909b8 100644 --- a/src/libs/Baseten/Generated/Baseten.Models.TrainingJobV1.g.cs +++ b/src/libs/Baseten/Generated/Baseten.Models.TrainingJobV1.g.cs @@ -30,7 +30,7 @@ public sealed partial class TrainingJobV1 public required string CurrentStatus { get; set; } /// - /// Error message if the training job failed.
+ /// Error message if the training job failed. While the job is pending, a hint when switching it to spot capacity would let it start sooner.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 ///
[global::System.Text.Json.Serialization.JsonPropertyName("error_message")] @@ -138,7 +138,7 @@ public sealed partial class TrainingJobV1 /// Summary of the training project. /// /// - /// Error message if the training job failed.
+ /// Error message if the training job failed. While the job is pending, a hint when switching it to spot capacity would let it start sooner.
/// Default Value: openapi-json-null-sentinel-value-2BF93600-0FE4-4250-987A-E5DDB203E464 /// /// diff --git a/src/libs/Baseten/Generated/Baseten.Models.UpdateSandboxPreviewRequestV1.Json.g.cs b/src/libs/Baseten/Generated/Baseten.Models.UpdateSandboxPreviewRequestV1.Json.g.cs new file mode 100644 index 0000000..881b2ae --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.UpdateSandboxPreviewRequestV1.Json.g.cs @@ -0,0 +1,141 @@ +#nullable enable + +namespace Baseten +{ + public readonly partial struct UpdateSandboxPreviewRequestV1 + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the generated default JsonSerializerContext. + /// + public string ToJson() + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return ToJson(global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Baseten.UpdateSandboxPreviewRequestV1? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Baseten.UpdateSandboxPreviewRequestV1), + jsonSerializerContext) as global::Baseten.UpdateSandboxPreviewRequestV1?; + } + + /// + /// Deserializes a JSON string using the generated default JsonSerializerContext. + /// + public static global::Baseten.UpdateSandboxPreviewRequestV1? FromJson( + string json) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Baseten.UpdateSandboxPreviewRequestV1? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJson( + json, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Baseten.UpdateSandboxPreviewRequestV1), + jsonSerializerContext).ConfigureAwait(false)) as global::Baseten.UpdateSandboxPreviewRequestV1?; + } + + /// + /// Deserializes a JSON stream using the generated default JsonSerializerContext. + /// + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + if (jsonSerializerOptions is null) + { + return FromJsonStreamAsync( + jsonStream, + global::Baseten.SourceGenerationContext.Default); + } + + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Models.UpdateSandboxPreviewRequestV1.g.cs b/src/libs/Baseten/Generated/Baseten.Models.UpdateSandboxPreviewRequestV1.g.cs new file mode 100644 index 0000000..b4690e2 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Models.UpdateSandboxPreviewRequestV1.g.cs @@ -0,0 +1,202 @@ +#pragma warning disable CS0618 // Type or member is obsolete + +#nullable enable + +namespace Baseten +{ + /// + /// Preview fields to change. name and port cannot be changed. + /// + public readonly partial struct UpdateSandboxPreviewRequestV1 : global::System.IEquatable + { + /// + /// Mutable preview configuration. ttl and expires_at are mutually exclusive; supplying both returns 400. + /// +#if NET6_0_OR_GREATER + public global::Baseten.SandboxPreviewConfigurationV1? Configuration { get; init; } +#else + public global::Baseten.SandboxPreviewConfigurationV1? Configuration { get; } +#endif + + /// + /// + /// +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Configuration))] +#endif + public bool IsConfiguration => Configuration != null; + + /// + /// + /// + public bool TryPickConfiguration( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Baseten.SandboxPreviewConfigurationV1? value) + { + value = Configuration; + return IsConfiguration; + } + + /// + /// + /// + public global::Baseten.SandboxPreviewConfigurationV1 PickConfiguration() => Configuration is { } value + ? value + : throw new global::System.InvalidOperationException($"Expected union variant 'Configuration' but the value was {ToString()}."); + /// + /// + /// + public static implicit operator UpdateSandboxPreviewRequestV1(global::Baseten.SandboxPreviewConfigurationV1 value) => new UpdateSandboxPreviewRequestV1((global::Baseten.SandboxPreviewConfigurationV1?)value); + + /// + /// + /// + public static implicit operator global::Baseten.SandboxPreviewConfigurationV1?(UpdateSandboxPreviewRequestV1 @this) => @this.Configuration; + + /// + /// + /// + public UpdateSandboxPreviewRequestV1(global::Baseten.SandboxPreviewConfigurationV1? value) + { + Configuration = value; + } + + /// + /// + /// + public static UpdateSandboxPreviewRequestV1 FromConfiguration(global::Baseten.SandboxPreviewConfigurationV1? value) => new UpdateSandboxPreviewRequestV1(value); + + /// + /// + /// + public object? Object => + Configuration as object + ; + + /// + /// + /// + public override string? ToString() => + Configuration?.ToString() + ; + + /// + /// + /// + public bool Validate() + { + return IsConfiguration; + } + + /// + /// + /// + public TResult? Match( + global::System.Func? configuration = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0 && configuration != null) + { + return configuration(__value0); + } + + return default(TResult); + } + + /// + /// + /// + public void Match( + global::System.Action? configuration = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0) + { + configuration?.Invoke(__value0); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? configuration = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (Configuration is { } __value0) + { + configuration?.Invoke(__value0); + } + } + + /// + /// + /// + public override int GetHashCode() + { + var fields = new object?[] + { + Configuration, + typeof(global::Baseten.SandboxPreviewConfigurationV1), + }; + const int offset = unchecked((int)2166136261); + const int prime = 16777619; + static int HashCodeAggregator(int hashCode, object? value) => value == null + ? (hashCode ^ 0) * prime + : (hashCode ^ value.GetHashCode()) * prime; + + return global::System.Linq.Enumerable.Aggregate(fields, offset, HashCodeAggregator); + } + + /// + /// + /// + public bool Equals(UpdateSandboxPreviewRequestV1 other) + { + return + global::System.Collections.Generic.EqualityComparer.Default.Equals(Configuration, other.Configuration) + ; + } + + /// + /// + /// + public static bool operator ==(UpdateSandboxPreviewRequestV1 obj1, UpdateSandboxPreviewRequestV1 obj2) + { + return global::System.Collections.Generic.EqualityComparer.Default.Equals(obj1, obj2); + } + + /// + /// + /// + public static bool operator !=(UpdateSandboxPreviewRequestV1 obj1, UpdateSandboxPreviewRequestV1 obj2) + { + return !(obj1 == obj2); + } + + /// + /// + /// + public override bool Equals(object? obj) + { + return obj is UpdateSandboxPreviewRequestV1 o && Equals(o); + } + } +} diff --git a/src/libs/Baseten/Generated/Baseten.Previews.JsonSerializerContext.g.cs b/src/libs/Baseten/Generated/Baseten.Previews.JsonSerializerContext.g.cs new file mode 100644 index 0000000..0d4f82f --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.Previews.JsonSerializerContext.g.cs @@ -0,0 +1,202 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// + /// + [global::System.Text.Json.Serialization.JsonSourceGenerationOptions( + DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull + )] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.Dictionary))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.Dictionary))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List), TypeInfoPropertyName = "SystemCollectionsGeneric_ObjectList")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Text.Json.JsonElement?))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(bool))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(string))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.DateTime))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(int))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxApiPaginationV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewStatusV1), TypeInfoPropertyName = "SandboxPreviewStatusV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewConfigurationV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CreateSandboxPreviewRequestV1), TypeInfoPropertyName = "CreateSandboxPreviewRequestV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CreateSandboxPreviewRequestV1Variant2))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.UpdateSandboxPreviewRequestV1), TypeInfoPropertyName = "UpdateSandboxPreviewRequestV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewV1), TypeInfoPropertyName = "SandboxPreviewV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewV1Variant2))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.ListSandboxPreviewsResponseV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CreateSandboxPreviewTokenRequestV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewTokenV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.ListSandboxPreviewTokensResponseV1))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(bool?))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(int?))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewStatusV1?), TypeInfoPropertyName = "NullableSandboxPreviewStatusV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.CreateSandboxPreviewRequestV1?), TypeInfoPropertyName = "NullableCreateSandboxPreviewRequestV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.UpdateSandboxPreviewRequestV1?), TypeInfoPropertyName = "NullableUpdateSandboxPreviewRequestV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Baseten.SandboxPreviewV1?), TypeInfoPropertyName = "NullableSandboxPreviewV12")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + internal sealed partial class PreviewsSourceGenerationContextChunk0 : global::System.Text.Json.Serialization.JsonSerializerContext + { + } + /// + /// + /// + public sealed partial class PreviewsSourceGenerationContext : global::System.Text.Json.Serialization.JsonSerializerContext + { + private static readonly global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver Resolver = new LazyChunkResolver(); + + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + internal static global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver TypeInfoResolver => Resolver; + + + private static readonly global::System.Text.Json.JsonSerializerOptions DefaultOptions = CreateDefaultOptions(); + + /// + /// + /// + public static PreviewsSourceGenerationContext Default { get; } = new(DefaultOptions); + + private PreviewsSourceGenerationContext(global::System.Text.Json.JsonSerializerOptions options) + : base(options) + { + } + + /// + protected override global::System.Text.Json.JsonSerializerOptions? GeneratedSerializerOptions => DefaultOptions; + + /// + public override global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? GetTypeInfo(global::System.Type type) + { + return Resolver.GetTypeInfo(type, Options); + } + + /// + /// Adds this package's converters to . + /// + /// + /// A converter has to be on the options a chained resolver builds its JsonTypeInfo against, + /// and a context resolves types from every package below it. Each package contributes only + /// what it owns and calls down the chain for the rest, so the family's converter table is + /// written once rather than copied into all of them. + /// + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public static void AddConverters(global::System.Text.Json.JsonSerializerOptions options) + { + options.Converters.Add(new global::Baseten.JsonConverters.CreateSandboxPreviewRequestV1JsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.UpdateSandboxPreviewRequestV1JsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.SandboxPreviewV1JsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.AnyOfJsonConverter()); + options.Converters.Add(new global::Baseten.JsonConverters.UnixTimestampJsonConverter()); + options.Converters.Add(new LazyEnumJsonConverterFactory()); + } + + private static global::System.Text.Json.JsonSerializerOptions CreateDefaultOptions() + { + var options = new global::System.Text.Json.JsonSerializerOptions + { + DefaultIgnoreCondition = global::System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull, + TypeInfoResolver = Resolver, + }; + AddConverters(options); + + return options; + } + + + private sealed class LazyEnumJsonConverterFactory : global::System.Text.Json.Serialization.JsonConverterFactory + { + public override bool CanConvert(global::System.Type typeToConvert) + { + return + typeToConvert == typeof(global::Baseten.SandboxPreviewStatusV1) + + || typeToConvert == typeof(global::Baseten.SandboxPreviewStatusV1?); + } + + public override global::System.Text.Json.Serialization.JsonConverter CreateConverter( + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + if (typeToConvert == typeof(global::Baseten.SandboxPreviewStatusV1)) + { + return new global::Baseten.JsonConverters.SandboxPreviewStatusV1JsonConverter(); + } + + if (typeToConvert == typeof(global::Baseten.SandboxPreviewStatusV1?)) + { + return new global::Baseten.JsonConverters.SandboxPreviewStatusV1NullableJsonConverter(); + } + throw new global::System.NotSupportedException($"No generated enum converter is registered for '{typeToConvert}'."); + } + } + + private sealed class LazyChunkResolver : global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver + { + private readonly object _gate = new(); + private readonly global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver?[] _resolvers = new global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver?[1]; + + public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo? GetTypeInfo( + global::System.Type type, + global::System.Text.Json.JsonSerializerOptions options) + { + for (var index = 0; index < _resolvers.Length; index++) + { + var typeInfo = GetResolver(index).GetTypeInfo(type, options); + if (typeInfo is not null) + { + return typeInfo; + } + } + + return null; + } + + private global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver GetResolver(int index) + { + var resolver = global::System.Threading.Volatile.Read(ref _resolvers[index]); + if (resolver is not null) + { + return resolver; + } + + lock (_gate) + { + return _resolvers[index] ??= CreateResolver(index); + } + } + + private static global::System.Text.Json.Serialization.Metadata.IJsonTypeInfoResolver CreateResolver(int index) + { + return index switch + { + 0 => new PreviewsSourceGenerationContextChunk0(new global::System.Text.Json.JsonSerializerOptions()), + _ => throw new global::System.ArgumentOutOfRangeException(nameof(index)), + }; + } + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.PreviewsClient.Authorizations.Bearer.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.Authorizations.Bearer.g.cs new file mode 100644 index 0000000..442cc85 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.Authorizations.Bearer.g.cs @@ -0,0 +1,35 @@ + +#nullable enable + +namespace Baseten +{ + public sealed partial class PreviewsClient + { + + /// + public void AuthorizeUsingBearer( + string apiKey) + { + apiKey = apiKey ?? throw new global::System.ArgumentNullException(nameof(apiKey)); + + for (var i = Authorizations.Count - 1; i >= 0; i--) + { + var __authorization = Authorizations[i]; + if (__authorization.Type == "Http" && + __authorization.Name == "Bearer") + { + Authorizations.RemoveAt(i); + } + } + + Authorizations.Add(new global::Baseten.EndPointAuthorization + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + Value = apiKey, + }); + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.PreviewsClient.Constructors.Bearer.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.Constructors.Bearer.g.cs new file mode 100644 index 0000000..dac108b --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.Constructors.Bearer.g.cs @@ -0,0 +1,31 @@ + +#nullable enable + +namespace Baseten +{ + public sealed partial class PreviewsClient + { + /// + + public PreviewsClient( + string apiKey, + 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, disposeHttpClient) + { + Authorizing(HttpClient, ref apiKey); + + AuthorizeUsingBearer(apiKey); + + Authorized(HttpClient); + } + + partial void Authorizing( + global::System.Net.Http.HttpClient client, + ref string apiKey); + partial void Authorized( + global::System.Net.Http.HttpClient client); + + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.PreviewsClient.CreateSandboxPreview.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.CreateSandboxPreview.g.cs new file mode 100644 index 0000000..f00110f --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.CreateSandboxPreview.g.cs @@ -0,0 +1,724 @@ + +#nullable enable + +namespace Baseten +{ + public partial class PreviewsClient + { + + + private static readonly global::Baseten.EndPointSecurityRequirement s_CreateSandboxPreviewSecurityRequirement0 = + new global::Baseten.EndPointSecurityRequirement + { + Authorizations = new global::Baseten.EndPointAuthorizationRequirement[] + { new global::Baseten.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Baseten.EndPointSecurityRequirement[] s_CreateSandboxPreviewSecurityRequirements = + new global::Baseten.EndPointSecurityRequirement[] + { s_CreateSandboxPreviewSecurityRequirement0, + }; + partial void PrepareCreateSandboxPreviewArguments( + global::System.Net.Http.HttpClient httpClient, + ref string? teamId, + ref string? xTeamId, + ref string sandboxName, + global::Baseten.CreateSandboxPreviewRequestV1 request); + partial void PrepareCreateSandboxPreviewRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? teamId, + string? xTeamId, + string sandboxName, + global::Baseten.CreateSandboxPreviewRequestV1 request); + partial void ProcessCreateSandboxPreviewResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessCreateSandboxPreviewResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Create a sandbox preview
+ /// Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox's reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public-<port> or private-<port> when create_if_not_exists is true. + ///
+ /// + /// + /// + /// + /// 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 CreateSandboxPreviewAsync( + string sandboxName, + + global::Baseten.CreateSandboxPreviewRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateSandboxPreviewAsResponseAsync( + sandboxName: sandboxName, + + request: request, + teamId: teamId, + xTeamId: xTeamId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a sandbox preview
+ /// Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox's reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public-<port> or private-<port> when create_if_not_exists is true. + ///
+ /// + /// + /// + /// + /// 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> CreateSandboxPreviewAsResponseAsync( + string sandboxName, + + global::Baseten.CreateSandboxPreviewRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareCreateSandboxPreviewArguments( + httpClient: HttpClient, + teamId: ref teamId, + xTeamId: ref xTeamId, + sandboxName: ref sandboxName, + request: request); + + + var __authorizations = global::Baseten.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateSandboxPreviewSecurityRequirements, + operationName: "CreateSandboxPreviewAsync"); + + using var __timeoutCancellationTokenSource = global::Baseten.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Baseten.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Baseten.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Baseten.PathBuilder( + path: $"/v1/sandboxes/instances/{sandboxName}/previews", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("team_id", teamId) + ; + var __path = __pathBuilder.ToString(); + __path = global::Baseten.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTeamId != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Team-Id", xTeamId.ToString()); + } + + 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::Baseten.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateSandboxPreviewRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + teamId: teamId, + xTeamId: xTeamId, + sandboxName: sandboxName, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Baseten.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreview", + methodName: "CreateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreview", + methodName: "CreateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Baseten.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreview", + methodName: "CreateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateSandboxPreviewResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreview", + methodName: "CreateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreview", + methodName: "CreateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Invalid request. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Missing or invalid authentication. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Insufficient permissions. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource not found. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource is currently in use or conflicts with the requested operation. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 409) + { + string? __content_409 = null; + global::System.Exception? __exception_409 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_409 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_409 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_409 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_409 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_409, + responseBody: __content_409, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Request limit exceeded. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_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); + ProcessCreateSandboxPreviewResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Baseten.SandboxPreviewV1.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Baseten.SandboxPreviewV1.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Create a sandbox preview
+ /// Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox's reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public-<port> or private-<port> when create_if_not_exists is true. + ///
+ /// + /// + /// + /// 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 CreateSandboxPreviewAsync( + string sandboxName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Baseten.CreateSandboxPreviewRequestV1 + { + }; + + return await CreateSandboxPreviewAsync( + teamId: teamId, + xTeamId: xTeamId, + sandboxName: sandboxName, + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.PreviewsClient.CreateSandboxPreviewToken.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.CreateSandboxPreviewToken.g.cs new file mode 100644 index 0000000..6eb0d6d --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.CreateSandboxPreviewToken.g.cs @@ -0,0 +1,717 @@ + +#nullable enable + +namespace Baseten +{ + public partial class PreviewsClient + { + + + private static readonly global::Baseten.EndPointSecurityRequirement s_CreateSandboxPreviewTokenSecurityRequirement0 = + new global::Baseten.EndPointSecurityRequirement + { + Authorizations = new global::Baseten.EndPointAuthorizationRequirement[] + { new global::Baseten.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Baseten.EndPointSecurityRequirement[] s_CreateSandboxPreviewTokenSecurityRequirements = + new global::Baseten.EndPointSecurityRequirement[] + { s_CreateSandboxPreviewTokenSecurityRequirement0, + }; + partial void PrepareCreateSandboxPreviewTokenArguments( + global::System.Net.Http.HttpClient httpClient, + ref string? teamId, + ref string? xTeamId, + ref string sandboxName, + ref string previewName, + global::Baseten.CreateSandboxPreviewTokenRequestV1 request); + partial void PrepareCreateSandboxPreviewTokenRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? teamId, + string? xTeamId, + string sandboxName, + string previewName, + global::Baseten.CreateSandboxPreviewTokenRequestV1 request); + partial void ProcessCreateSandboxPreviewTokenResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessCreateSandboxPreviewTokenResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Create a preview token
+ /// Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=<token>. + ///
+ /// + /// + /// + /// + /// + /// 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 CreateSandboxPreviewTokenAsync( + string sandboxName, + string previewName, + + global::Baseten.CreateSandboxPreviewTokenRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateSandboxPreviewTokenAsResponseAsync( + sandboxName: sandboxName, + previewName: previewName, + + request: request, + teamId: teamId, + xTeamId: xTeamId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a preview token
+ /// Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=<token>. + ///
+ /// + /// + /// + /// + /// + /// 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> CreateSandboxPreviewTokenAsResponseAsync( + string sandboxName, + string previewName, + + global::Baseten.CreateSandboxPreviewTokenRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + PrepareArguments( + client: HttpClient); + PrepareCreateSandboxPreviewTokenArguments( + httpClient: HttpClient, + teamId: ref teamId, + xTeamId: ref xTeamId, + sandboxName: ref sandboxName, + previewName: ref previewName, + request: request); + + + var __authorizations = global::Baseten.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreateSandboxPreviewTokenSecurityRequirements, + operationName: "CreateSandboxPreviewTokenAsync"); + + using var __timeoutCancellationTokenSource = global::Baseten.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Baseten.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Baseten.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Baseten.PathBuilder( + path: $"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("team_id", teamId) + ; + var __path = __pathBuilder.ToString(); + __path = global::Baseten.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTeamId != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Team-Id", xTeamId.ToString()); + } + + 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::Baseten.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateSandboxPreviewTokenRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + teamId: teamId, + xTeamId: xTeamId, + sandboxName: sandboxName, + previewName: previewName, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Baseten.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreviewToken", + methodName: "CreateSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreviewToken", + methodName: "CreateSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Baseten.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreviewToken", + methodName: "CreateSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateSandboxPreviewTokenResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreviewToken", + methodName: "CreateSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSandboxPreviewToken", + methodName: "CreateSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Invalid request. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Missing or invalid authentication. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Insufficient permissions. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource not found. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Request limit exceeded. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_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); + ProcessCreateSandboxPreviewTokenResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Baseten.SandboxPreviewTokenV1.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Baseten.SandboxPreviewTokenV1.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Create a preview token
+ /// Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=<token>. + ///
+ /// + /// + /// + /// + /// + /// When true, return an existing unexpired token of this preview that stays valid at least until expires_at instead of creating a new one. Defaults to false when omitted. + /// + /// + /// Time at which the token stops working. Must be in the future.
+ /// Example: 2026-10-13T12:00:00Z + /// + /// 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 CreateSandboxPreviewTokenAsync( + string sandboxName, + string previewName, + global::System.DateTime expiresAt, + string? teamId = default, + string? xTeamId = default, + bool? createIfNotExists = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Baseten.CreateSandboxPreviewTokenRequestV1 + { + CreateIfNotExists = createIfNotExists, + ExpiresAt = expiresAt, + }; + + return await CreateSandboxPreviewTokenAsync( + teamId: teamId, + xTeamId: xTeamId, + sandboxName: sandboxName, + previewName: previewName, + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.PreviewsClient.DeleteSandboxPreview.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.DeleteSandboxPreview.g.cs new file mode 100644 index 0000000..a8c1643 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.DeleteSandboxPreview.g.cs @@ -0,0 +1,622 @@ + +#nullable enable + +namespace Baseten +{ + public partial class PreviewsClient + { + + + private static readonly global::Baseten.EndPointSecurityRequirement s_DeleteSandboxPreviewSecurityRequirement0 = + new global::Baseten.EndPointSecurityRequirement + { + Authorizations = new global::Baseten.EndPointAuthorizationRequirement[] + { new global::Baseten.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Baseten.EndPointSecurityRequirement[] s_DeleteSandboxPreviewSecurityRequirements = + new global::Baseten.EndPointSecurityRequirement[] + { s_DeleteSandboxPreviewSecurityRequirement0, + }; + partial void PrepareDeleteSandboxPreviewArguments( + global::System.Net.Http.HttpClient httpClient, + ref string? teamId, + ref string? xTeamId, + ref string sandboxName, + ref string previewName); + partial void PrepareDeleteSandboxPreviewRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? teamId, + string? xTeamId, + string sandboxName, + string previewName); + partial void ProcessDeleteSandboxPreviewResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessDeleteSandboxPreviewResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Delete a sandbox preview
+ /// Delete the preview and revoke its tokens. The URL stops serving immediately. Return the deleted preview, with status TERMINATED, or DELETING while a preview with many tokens finishes in the background. + ///
+ /// + /// + /// + /// + /// 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 DeleteSandboxPreviewAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await DeleteSandboxPreviewAsResponseAsync( + sandboxName: sandboxName, + previewName: previewName, + teamId: teamId, + xTeamId: xTeamId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Delete a sandbox preview
+ /// Delete the preview and revoke its tokens. The URL stops serving immediately. Return the deleted preview, with status TERMINATED, or DELETING while a preview with many tokens finishes in the background. + ///
+ /// + /// + /// + /// + /// 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> DeleteSandboxPreviewAsResponseAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareDeleteSandboxPreviewArguments( + httpClient: HttpClient, + teamId: ref teamId, + xTeamId: ref xTeamId, + sandboxName: ref sandboxName, + previewName: ref previewName); + + + var __authorizations = global::Baseten.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_DeleteSandboxPreviewSecurityRequirements, + operationName: "DeleteSandboxPreviewAsync"); + + using var __timeoutCancellationTokenSource = global::Baseten.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Baseten.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Baseten.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Baseten.PathBuilder( + path: $"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("team_id", teamId) + ; + var __path = __pathBuilder.ToString(); + __path = global::Baseten.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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTeamId != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Team-Id", xTeamId.ToString()); + } + + global::Baseten.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteSandboxPreviewRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + teamId: teamId, + xTeamId: xTeamId, + sandboxName: sandboxName, + previewName: previewName); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Baseten.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreview", + methodName: "DeleteSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreview", + methodName: "DeleteSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Baseten.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreview", + methodName: "DeleteSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteSandboxPreviewResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreview", + methodName: "DeleteSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreview", + methodName: "DeleteSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Missing or invalid authentication. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Insufficient permissions. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource not found. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Request limit exceeded. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_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); + ProcessDeleteSandboxPreviewResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Baseten.SandboxPreviewV1.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Baseten.SandboxPreviewV1.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + 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/Baseten/Generated/Baseten.PreviewsClient.DeleteSandboxPreviewToken.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.DeleteSandboxPreviewToken.g.cs new file mode 100644 index 0000000..54a223d --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.DeleteSandboxPreviewToken.g.cs @@ -0,0 +1,608 @@ + +#nullable enable + +namespace Baseten +{ + public partial class PreviewsClient + { + + + private static readonly global::Baseten.EndPointSecurityRequirement s_DeleteSandboxPreviewTokenSecurityRequirement0 = + new global::Baseten.EndPointSecurityRequirement + { + Authorizations = new global::Baseten.EndPointAuthorizationRequirement[] + { new global::Baseten.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Baseten.EndPointSecurityRequirement[] s_DeleteSandboxPreviewTokenSecurityRequirements = + new global::Baseten.EndPointSecurityRequirement[] + { s_DeleteSandboxPreviewTokenSecurityRequirement0, + }; + partial void PrepareDeleteSandboxPreviewTokenArguments( + global::System.Net.Http.HttpClient httpClient, + ref string? teamId, + ref string? xTeamId, + ref string sandboxName, + ref string previewName, + ref string tokenName); + partial void PrepareDeleteSandboxPreviewTokenRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? teamId, + string? xTeamId, + string sandboxName, + string previewName, + string tokenName); + partial void ProcessDeleteSandboxPreviewTokenResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Delete a preview token
+ /// Revoke the token. Requests using it are rejected immediately. + ///
+ /// + /// + /// + /// + /// + /// 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 DeleteSandboxPreviewTokenAsync( + string sandboxName, + string previewName, + string tokenName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + await DeleteSandboxPreviewTokenAsResponseAsync( + sandboxName: sandboxName, + previewName: previewName, + tokenName: tokenName, + teamId: teamId, + xTeamId: xTeamId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Delete a preview token
+ /// Revoke the token. Requests using it are rejected immediately. + ///
+ /// + /// + /// + /// + /// + /// 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 DeleteSandboxPreviewTokenAsResponseAsync( + string sandboxName, + string previewName, + string tokenName, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareDeleteSandboxPreviewTokenArguments( + httpClient: HttpClient, + teamId: ref teamId, + xTeamId: ref xTeamId, + sandboxName: ref sandboxName, + previewName: ref previewName, + tokenName: ref tokenName); + + + var __authorizations = global::Baseten.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_DeleteSandboxPreviewTokenSecurityRequirements, + operationName: "DeleteSandboxPreviewTokenAsync"); + + using var __timeoutCancellationTokenSource = global::Baseten.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Baseten.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Baseten.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Baseten.PathBuilder( + path: $"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens/{tokenName}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("team_id", teamId) + ; + var __path = __pathBuilder.ToString(); + __path = global::Baseten.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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTeamId != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Team-Id", xTeamId.ToString()); + } + + global::Baseten.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteSandboxPreviewTokenRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + teamId: teamId, + xTeamId: xTeamId, + sandboxName: sandboxName, + previewName: previewName, + tokenName: tokenName); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Baseten.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreviewToken", + methodName: "DeleteSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens/{tokenName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreviewToken", + methodName: "DeleteSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens/{tokenName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Baseten.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreviewToken", + methodName: "DeleteSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens/{tokenName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDeleteSandboxPreviewTokenResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreviewToken", + methodName: "DeleteSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens/{tokenName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSandboxPreviewToken", + methodName: "DeleteSandboxPreviewTokenAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens/{tokenName}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Missing or invalid authentication. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Insufficient permissions. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource not found. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Request limit exceeded. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_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); + + try + { + __response.EnsureSuccessStatusCode(); + + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + catch (global::System.Exception __ex) + { + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); + } + 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 global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + 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/Baseten/Generated/Baseten.PreviewsClient.GetSandboxPreview.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.GetSandboxPreview.g.cs new file mode 100644 index 0000000..542c0fa --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.GetSandboxPreview.g.cs @@ -0,0 +1,636 @@ + +#nullable enable + +namespace Baseten +{ + public partial class PreviewsClient + { + + + private static readonly global::Baseten.EndPointSecurityRequirement s_GetSandboxPreviewSecurityRequirement0 = + new global::Baseten.EndPointSecurityRequirement + { + Authorizations = new global::Baseten.EndPointAuthorizationRequirement[] + { new global::Baseten.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Baseten.EndPointSecurityRequirement[] s_GetSandboxPreviewSecurityRequirements = + new global::Baseten.EndPointSecurityRequirement[] + { s_GetSandboxPreviewSecurityRequirement0, + }; + partial void PrepareGetSandboxPreviewArguments( + global::System.Net.Http.HttpClient httpClient, + ref string? teamId, + ref string? xTeamId, + ref bool? showSecrets, + ref string sandboxName, + ref string previewName); + partial void PrepareGetSandboxPreviewRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? teamId, + string? xTeamId, + bool? showSecrets, + string sandboxName, + string previewName); + partial void ProcessGetSandboxPreviewResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessGetSandboxPreviewResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Get a sandbox preview
+ /// Return the preview configuration, URL and status. + ///
+ /// + /// + /// + /// Default Value: false + /// + /// + /// + /// 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 GetSandboxPreviewAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + bool? showSecrets = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetSandboxPreviewAsResponseAsync( + sandboxName: sandboxName, + previewName: previewName, + teamId: teamId, + xTeamId: xTeamId, + showSecrets: showSecrets, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get a sandbox preview
+ /// Return the preview configuration, URL and status. + ///
+ /// + /// + /// + /// Default Value: false + /// + /// + /// + /// 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> GetSandboxPreviewAsResponseAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + bool? showSecrets = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetSandboxPreviewArguments( + httpClient: HttpClient, + teamId: ref teamId, + xTeamId: ref xTeamId, + showSecrets: ref showSecrets, + sandboxName: ref sandboxName, + previewName: ref previewName); + + + var __authorizations = global::Baseten.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetSandboxPreviewSecurityRequirements, + operationName: "GetSandboxPreviewAsync"); + + using var __timeoutCancellationTokenSource = global::Baseten.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Baseten.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Baseten.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Baseten.PathBuilder( + path: $"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("team_id", teamId) + .AddOptionalParameter("show_secrets", showSecrets?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Baseten.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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTeamId != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Team-Id", xTeamId.ToString()); + } + + global::Baseten.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetSandboxPreviewRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + teamId: teamId, + xTeamId: xTeamId, + showSecrets: showSecrets, + sandboxName: sandboxName, + previewName: previewName); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Baseten.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSandboxPreview", + methodName: "GetSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSandboxPreview", + methodName: "GetSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Baseten.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSandboxPreview", + methodName: "GetSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetSandboxPreviewResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSandboxPreview", + methodName: "GetSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetSandboxPreview", + methodName: "GetSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Missing or invalid authentication. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Insufficient permissions. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource not found. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Request limit exceeded. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_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); + ProcessGetSandboxPreviewResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Baseten.SandboxPreviewV1.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Baseten.SandboxPreviewV1.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + 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/Baseten/Generated/Baseten.PreviewsClient.ListSandboxPreviewTokens.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.ListSandboxPreviewTokens.g.cs new file mode 100644 index 0000000..cc34a05 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.ListSandboxPreviewTokens.g.cs @@ -0,0 +1,684 @@ + +#nullable enable + +namespace Baseten +{ + public partial class PreviewsClient + { + + + private static readonly global::Baseten.EndPointSecurityRequirement s_ListSandboxPreviewTokensSecurityRequirement0 = + new global::Baseten.EndPointSecurityRequirement + { + Authorizations = new global::Baseten.EndPointAuthorizationRequirement[] + { new global::Baseten.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Baseten.EndPointSecurityRequirement[] s_ListSandboxPreviewTokensSecurityRequirements = + new global::Baseten.EndPointSecurityRequirement[] + { s_ListSandboxPreviewTokensSecurityRequirement0, + }; + partial void PrepareListSandboxPreviewTokensArguments( + global::System.Net.Http.HttpClient httpClient, + ref string? teamId, + ref string? xTeamId, + ref string? cursor, + ref int? limit, + ref string sandboxName, + ref string previewName); + partial void PrepareListSandboxPreviewTokensRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? teamId, + string? xTeamId, + string? cursor, + int? limit, + string sandboxName, + string previewName); + partial void ProcessListSandboxPreviewTokensResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessListSandboxPreviewTokensResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// List preview tokens
+ /// Return the tokens of a private preview in the paginated list format, including expired tokens until they are removed. cursor and limit are accepted but not applied yet; all tokens fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied. + ///
+ /// + /// + /// + /// Example: eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ + /// + /// + /// Default Value: 20
+ /// Example: 20 + /// + /// + /// + /// 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 ListSandboxPreviewTokensAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + string? cursor = default, + int? limit = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListSandboxPreviewTokensAsResponseAsync( + sandboxName: sandboxName, + previewName: previewName, + teamId: teamId, + xTeamId: xTeamId, + cursor: cursor, + limit: limit, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List preview tokens
+ /// Return the tokens of a private preview in the paginated list format, including expired tokens until they are removed. cursor and limit are accepted but not applied yet; all tokens fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied. + ///
+ /// + /// + /// + /// Example: eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ + /// + /// + /// Default Value: 20
+ /// Example: 20 + /// + /// + /// + /// 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> ListSandboxPreviewTokensAsResponseAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + string? cursor = default, + int? limit = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareListSandboxPreviewTokensArguments( + httpClient: HttpClient, + teamId: ref teamId, + xTeamId: ref xTeamId, + cursor: ref cursor, + limit: ref limit, + sandboxName: ref sandboxName, + previewName: ref previewName); + + + var __authorizations = global::Baseten.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ListSandboxPreviewTokensSecurityRequirements, + operationName: "ListSandboxPreviewTokensAsync"); + + using var __timeoutCancellationTokenSource = global::Baseten.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Baseten.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Baseten.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Baseten.PathBuilder( + path: $"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("team_id", teamId) + .AddOptionalParameter("cursor", cursor) + .AddOptionalParameter("limit", limit?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Baseten.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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTeamId != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Team-Id", xTeamId.ToString()); + } + + global::Baseten.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListSandboxPreviewTokensRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + teamId: teamId, + xTeamId: xTeamId, + cursor: cursor, + limit: limit, + sandboxName: sandboxName, + previewName: previewName); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Baseten.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviewTokens", + methodName: "ListSandboxPreviewTokensAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviewTokens", + methodName: "ListSandboxPreviewTokensAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Baseten.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviewTokens", + methodName: "ListSandboxPreviewTokensAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListSandboxPreviewTokensResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviewTokens", + methodName: "ListSandboxPreviewTokensAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviewTokens", + methodName: "ListSandboxPreviewTokensAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}/tokens\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // The preview is public, so it has no tokens. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Missing or invalid authentication. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Insufficient permissions. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource not found. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Request limit exceeded. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_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); + ProcessListSandboxPreviewTokensResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Baseten.ListSandboxPreviewTokensResponseV1.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Baseten.ListSandboxPreviewTokensResponseV1.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + 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/Baseten/Generated/Baseten.PreviewsClient.ListSandboxPreviews.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.ListSandboxPreviews.g.cs new file mode 100644 index 0000000..15dfd47 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.ListSandboxPreviews.g.cs @@ -0,0 +1,643 @@ + +#nullable enable + +namespace Baseten +{ + public partial class PreviewsClient + { + + + private static readonly global::Baseten.EndPointSecurityRequirement s_ListSandboxPreviewsSecurityRequirement0 = + new global::Baseten.EndPointSecurityRequirement + { + Authorizations = new global::Baseten.EndPointAuthorizationRequirement[] + { new global::Baseten.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Baseten.EndPointSecurityRequirement[] s_ListSandboxPreviewsSecurityRequirements = + new global::Baseten.EndPointSecurityRequirement[] + { s_ListSandboxPreviewsSecurityRequirement0, + }; + partial void PrepareListSandboxPreviewsArguments( + global::System.Net.Http.HttpClient httpClient, + ref string? teamId, + ref string? xTeamId, + ref string? cursor, + ref int? limit, + ref string sandboxName); + partial void PrepareListSandboxPreviewsRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? teamId, + string? xTeamId, + string? cursor, + int? limit, + string sandboxName); + partial void ProcessListSandboxPreviewsResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessListSandboxPreviewsResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// List sandbox previews
+ /// Return the previews of the sandbox in the paginated list format. cursor and limit are accepted but not applied yet; all previews fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied. + ///
+ /// + /// + /// + /// Example: eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ + /// + /// + /// Default Value: 20
+ /// Example: 20 + /// + /// + /// 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 ListSandboxPreviewsAsync( + string sandboxName, + string? teamId = default, + string? xTeamId = default, + string? cursor = default, + int? limit = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListSandboxPreviewsAsResponseAsync( + sandboxName: sandboxName, + teamId: teamId, + xTeamId: xTeamId, + cursor: cursor, + limit: limit, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List sandbox previews
+ /// Return the previews of the sandbox in the paginated list format. cursor and limit are accepted but not applied yet; all previews fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied. + ///
+ /// + /// + /// + /// Example: eyJ2IjoxLCJsYXN0X2tleSI6ImJhc2V0ZW4tYXBpLXJldmlldy0wOTE2Iiwic29ydCI6ImRlc2MifQ + /// + /// + /// Default Value: 20
+ /// Example: 20 + /// + /// + /// 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> ListSandboxPreviewsAsResponseAsync( + string sandboxName, + string? teamId = default, + string? xTeamId = default, + string? cursor = default, + int? limit = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareListSandboxPreviewsArguments( + httpClient: HttpClient, + teamId: ref teamId, + xTeamId: ref xTeamId, + cursor: ref cursor, + limit: ref limit, + sandboxName: ref sandboxName); + + + var __authorizations = global::Baseten.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ListSandboxPreviewsSecurityRequirements, + operationName: "ListSandboxPreviewsAsync"); + + using var __timeoutCancellationTokenSource = global::Baseten.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Baseten.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Baseten.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Baseten.PathBuilder( + path: $"/v1/sandboxes/instances/{sandboxName}/previews", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("team_id", teamId) + .AddOptionalParameter("cursor", cursor) + .AddOptionalParameter("limit", limit?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Baseten.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; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTeamId != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Team-Id", xTeamId.ToString()); + } + + global::Baseten.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListSandboxPreviewsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + teamId: teamId, + xTeamId: xTeamId, + cursor: cursor, + limit: limit, + sandboxName: sandboxName); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Baseten.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviews", + methodName: "ListSandboxPreviewsAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviews", + methodName: "ListSandboxPreviewsAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Baseten.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviews", + methodName: "ListSandboxPreviewsAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListSandboxPreviewsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviews", + methodName: "ListSandboxPreviewsAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListSandboxPreviews", + methodName: "ListSandboxPreviewsAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Missing or invalid authentication. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Insufficient permissions. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource not found. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Request limit exceeded. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_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); + ProcessListSandboxPreviewsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Baseten.ListSandboxPreviewsResponseV1.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Baseten.ListSandboxPreviewsResponseV1.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + 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/Baseten/Generated/Baseten.PreviewsClient.UpdateSandboxPreview.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.UpdateSandboxPreview.g.cs new file mode 100644 index 0000000..482ced3 --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.UpdateSandboxPreview.g.cs @@ -0,0 +1,767 @@ + +#nullable enable + +namespace Baseten +{ + public partial class PreviewsClient + { + + + private static readonly global::Baseten.EndPointSecurityRequirement s_UpdateSandboxPreviewSecurityRequirement0 = + new global::Baseten.EndPointSecurityRequirement + { + Authorizations = new global::Baseten.EndPointAuthorizationRequirement[] + { new global::Baseten.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Baseten.EndPointSecurityRequirement[] s_UpdateSandboxPreviewSecurityRequirements = + new global::Baseten.EndPointSecurityRequirement[] + { s_UpdateSandboxPreviewSecurityRequirement0, + }; + partial void PrepareUpdateSandboxPreviewArguments( + global::System.Net.Http.HttpClient httpClient, + ref string? teamId, + ref string? xTeamId, + ref string sandboxName, + ref string previewName, + global::Baseten.UpdateSandboxPreviewRequestV1 request); + partial void PrepareUpdateSandboxPreviewRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string? teamId, + string? xTeamId, + string sandboxName, + string previewName, + global::Baseten.UpdateSandboxPreviewRequestV1 request); + partial void ProcessUpdateSandboxPreviewResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessUpdateSandboxPreviewResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Update a sandbox preview
+ /// Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400. + ///
+ /// + /// + /// + /// + /// + /// 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 UpdateSandboxPreviewAsync( + string sandboxName, + string previewName, + + global::Baseten.UpdateSandboxPreviewRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await UpdateSandboxPreviewAsResponseAsync( + sandboxName: sandboxName, + previewName: previewName, + + request: request, + teamId: teamId, + xTeamId: xTeamId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Update a sandbox preview
+ /// Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400. + ///
+ /// + /// + /// + /// + /// + /// 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> UpdateSandboxPreviewAsResponseAsync( + string sandboxName, + string previewName, + + global::Baseten.UpdateSandboxPreviewRequestV1 request, + string? teamId = default, + string? xTeamId = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareUpdateSandboxPreviewArguments( + httpClient: HttpClient, + teamId: ref teamId, + xTeamId: ref xTeamId, + sandboxName: ref sandboxName, + previewName: ref previewName, + request: request); + + + var __authorizations = global::Baseten.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_UpdateSandboxPreviewSecurityRequirements, + operationName: "UpdateSandboxPreviewAsync"); + + using var __timeoutCancellationTokenSource = global::Baseten.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Baseten.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Baseten.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Baseten.PathBuilder( + path: $"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("team_id", teamId) + ; + var __path = __pathBuilder.ToString(); + __path = global::Baseten.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: new global::System.Net.Http.HttpMethod("PATCH"), + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTeamId != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Team-Id", xTeamId.ToString()); + } + + 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::Baseten.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateSandboxPreviewRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + teamId: teamId, + xTeamId: xTeamId, + sandboxName: sandboxName, + previewName: previewName, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Baseten.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSandboxPreview", + methodName: "UpdateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSandboxPreview", + methodName: "UpdateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Baseten.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Baseten.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSandboxPreview", + methodName: "UpdateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Baseten.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUpdateSandboxPreviewResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSandboxPreview", + methodName: "UpdateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Baseten.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Baseten.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSandboxPreview", + methodName: "UpdateSandboxPreviewAsync", + pathTemplate: "$\"/v1/sandboxes/instances/{sandboxName}/previews/{previewName}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Invalid request. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Missing or invalid authentication. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Insufficient permissions. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource not found. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Resource is currently in use or conflicts with the requested operation. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 409) + { + string? __content_409 = null; + global::System.Exception? __exception_409 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_409 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_409 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_409 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_409 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_409, + responseBody: __content_409, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Request limit exceeded. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. Returns a JSON error with code, message, and optional details. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_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); + ProcessUpdateSandboxPreviewResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Baseten.SandboxPreviewV1.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Baseten.SandboxPreviewV1.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Baseten.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Baseten.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Baseten.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Update a sandbox preview
+ /// Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400. + ///
+ /// + /// + /// + /// + /// + /// Whether the URL is reachable without a preview token. Defaults to false.
+ /// Default Value: false
+ /// Example: true + /// + /// + /// Headers added to every response served by the preview, for example CORS headers. + /// + /// + /// Headers added to every request forwarded to the sandbox, for example an Authorization header expected by the application. Responses return each name with the value "****", except a GET with show_secrets=true by a workspace administrator. Sending "****" back as a value returns 400. A PATCH replaces the whole set.
+ /// Example: {"Authorization":"Bearer app-internal-token"} + /// + /// + /// Lifetime counted from the request, using seconds, minutes, hours or composite durations such as 1h30m. Whole days are also supported, for example 7d; days cannot be combined with other units. The preview is deleted when it elapses.
+ /// Example: 24h + /// + /// + /// Time at which the preview is deleted. Must be in the future.
+ /// Example: 2026-10-19T12:00:00Z + /// + /// 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 UpdateSandboxPreviewAsync( + string sandboxName, + string previewName, + string? teamId = default, + string? xTeamId = default, + bool? @public = default, + global::System.Collections.Generic.Dictionary? responseHeaders = default, + global::System.Collections.Generic.Dictionary? requestHeaders = default, + string? ttl = default, + global::System.DateTime? expiresAt = default, + global::Baseten.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Baseten.UpdateSandboxPreviewRequestV1( + new global::Baseten.SandboxPreviewConfigurationV1 + { + Public = @public, + ResponseHeaders = responseHeaders, + RequestHeaders = requestHeaders, + Ttl = ttl, + ExpiresAt = expiresAt, + }); + + return await UpdateSandboxPreviewAsync( + teamId: teamId, + xTeamId: xTeamId, + sandboxName: sandboxName, + previewName: previewName, + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/Baseten.PreviewsClient.g.cs b/src/libs/Baseten/Generated/Baseten.PreviewsClient.g.cs new file mode 100644 index 0000000..dae084d --- /dev/null +++ b/src/libs/Baseten/Generated/Baseten.PreviewsClient.g.cs @@ -0,0 +1,143 @@ + +#nullable enable + +namespace Baseten +{ + /// + /// 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. + ///
+ public sealed partial class PreviewsClient : global::Baseten.IPreviewsClient, global::System.IDisposable + { + /// + /// + /// + public const string DefaultBaseUrl = "https://api.baseten.co/"; + + private bool _disposeHttpClient = true; + + /// + public global::System.Net.Http.HttpClient HttpClient { get; } + + /// + public System.Uri? BaseUri => HttpClient.BaseAddress; + + /// + public global::System.Collections.Generic.List Authorizations { get; } + + /// + public bool ReadResponseAsString { get; set; } +#if DEBUG + = true; +#endif + + /// + public global::Baseten.AutoSDKClientOptions Options { get; } + + internal global::System.Lazy JsonSerializerContextProvider { get; set; } = new(() => global::Baseten.PreviewsSourceGenerationContext.Default); + + /// + /// + /// + public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext + { + get => JsonSerializerContextProvider.Value; + set => JsonSerializerContextProvider = new(() => value); + } + + + /// + /// Creates a new instance of the PreviewsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Dispose the HttpClient when the instance is disposed. True by default. + public PreviewsClient( + 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 PreviewsClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// 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 PreviewsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Collections.Generic.List? authorizations, + global::Baseten.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the PreviewsClient. + /// 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 PreviewsClient( + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Baseten.AutoSDKClientOptions? options, + 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::Baseten.AutoSDKClientOptions(); + _disposeHttpClient = disposeHttpClient; + + Initialized(HttpClient); + } + + /// + public void Dispose() + { + if (_disposeHttpClient) + { + HttpClient.Dispose(); + } + } + + partial void Initialized( + global::System.Net.Http.HttpClient client); + partial void PrepareArguments( + global::System.Net.Http.HttpClient client); + partial void PrepareRequest( + global::System.Net.Http.HttpClient client, + global::System.Net.Http.HttpRequestMessage request); + partial void ProcessResponse( + global::System.Net.Http.HttpClient client, + global::System.Net.Http.HttpResponseMessage response); + partial void ProcessResponseContent( + global::System.Net.Http.HttpClient client, + global::System.Net.Http.HttpResponseMessage response, + ref string content); + } +} \ No newline at end of file diff --git a/src/libs/Baseten/Generated/autosdk.generated-examples.json b/src/libs/Baseten/Generated/autosdk.generated-examples.json index 32697e0..1a624cc 100644 --- a/src/libs/Baseten/Generated/autosdk.generated-examples.json +++ b/src/libs/Baseten/Generated/autosdk.generated-examples.json @@ -101,6 +101,94 @@ }, { "Order": 10, + "Title": "Create a sandbox preview", + "Slug": "createsandboxpreview", + "Description": "Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox\u0027s reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public-\u003Cport\u003E or private-\u003Cport\u003E when create_if_not_exists is true.", + "Language": "http", + "Code": "### Create a sandbox preview\n# @name CreateSandboxPreview\nPOST {{host}}/v1/sandboxes/instances/{{sandbox_name}}/previews?team_id={{team_id}}\nAuthorization: Bearer {{token}}\nX-Team-Id: {{X-Team-Id}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022port\u0022: 8080,\n \u0022ttl\u0022: \u002224h\u0022\n}\n\n## Responses\n# 201\n# Description: Preview created.\n# Content-Type: application/json\n# 400\n# Description: Invalid request. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 401\n# Description: Missing or invalid authentication. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 403\n# Description: Insufficient permissions. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 404\n# Description: Resource not found. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 409\n# Description: Resource is currently in use or conflicts with the requested operation. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 429\n# Description: Request limit exceeded. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 500\n# Description: Internal server error. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json", + "Format": "http", + "OperationId": "CreateSandboxPreview", + "Setup": null + }, + { + "Order": 11, + "Title": "Create a preview token", + "Slug": "createsandboxpreviewtoken", + "Description": "Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=\u003Ctoken\u003E.", + "Language": "http", + "Code": "### Create a preview token\n# @name CreateSandboxPreviewToken\nPOST {{host}}/v1/sandboxes/instances/{{sandbox_name}}/previews/{{preview_name}}/tokens?team_id={{team_id}}\nAuthorization: Bearer {{token}}\nX-Team-Id: {{X-Team-Id}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022expires_at\u0022: \u00222026-10-13T12:00:00Z\u0022\n}\n\n## Responses\n# 201\n# Description: Token created.\n# Content-Type: application/json\n# 400\n# Description: Invalid request. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 401\n# Description: Missing or invalid authentication. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 403\n# Description: Insufficient permissions. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 404\n# Description: Resource not found. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 429\n# Description: Request limit exceeded. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 500\n# Description: Internal server error. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json", + "Format": "http", + "OperationId": "CreateSandboxPreviewToken", + "Setup": null + }, + { + "Order": 12, + "Title": "Delete a sandbox preview", + "Slug": "deletesandboxpreview", + "Description": "Delete the preview and revoke its tokens. The URL stops serving immediately. Return the deleted preview, with status TERMINATED, or DELETING while a preview with many tokens finishes in the background.", + "Language": "http", + "Code": "### Delete a sandbox preview\n# @name DeleteSandboxPreview\nDELETE {{host}}/v1/sandboxes/instances/{{sandbox_name}}/previews/{{preview_name}}?team_id={{team_id}}\nAuthorization: Bearer {{token}}\nX-Team-Id: {{X-Team-Id}}\nAccept: application/json\n\n## Responses\n# 200\n# Description: Successful operation.\n# Content-Type: application/json\n# 401\n# Description: Missing or invalid authentication. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 403\n# Description: Insufficient permissions. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 404\n# Description: Resource not found. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 429\n# Description: Request limit exceeded. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 500\n# Description: Internal server error. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json", + "Format": "http", + "OperationId": "DeleteSandboxPreview", + "Setup": null + }, + { + "Order": 13, + "Title": "Delete a preview token", + "Slug": "deletesandboxpreviewtoken", + "Description": "Revoke the token. Requests using it are rejected immediately.", + "Language": "http", + "Code": "### Delete a preview token\n# @name DeleteSandboxPreviewToken\nDELETE {{host}}/v1/sandboxes/instances/{{sandbox_name}}/previews/{{preview_name}}/tokens/{{token_name}}?team_id={{team_id}}\nAuthorization: Bearer {{token}}\nX-Team-Id: {{X-Team-Id}}\nAccept: application/json\n\n## Responses\n# 204\n# Description: Token deleted.\n# 401\n# Description: Missing or invalid authentication. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 403\n# Description: Insufficient permissions. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 404\n# Description: Resource not found. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 429\n# Description: Request limit exceeded. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 500\n# Description: Internal server error. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json", + "Format": "http", + "OperationId": "DeleteSandboxPreviewToken", + "Setup": null + }, + { + "Order": 14, + "Title": "Get a sandbox preview", + "Slug": "getsandboxpreview", + "Description": "Return the preview configuration, URL and status.", + "Language": "http", + "Code": "### Get a sandbox preview\n# @name GetSandboxPreview\nGET {{host}}/v1/sandboxes/instances/{{sandbox_name}}/previews/{{preview_name}}?team_id={{team_id}}\u0026show_secrets=false\nAuthorization: Bearer {{token}}\nX-Team-Id: {{X-Team-Id}}\nAccept: application/json\n\n## Responses\n# 200\n# Description: Successful operation.\n# Content-Type: application/json\n# 401\n# Description: Missing or invalid authentication. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 403\n# Description: Insufficient permissions. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 404\n# Description: Resource not found. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 429\n# Description: Request limit exceeded. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 500\n# Description: Internal server error. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json", + "Format": "http", + "OperationId": "GetSandboxPreview", + "Setup": null + }, + { + "Order": 15, + "Title": "List preview tokens", + "Slug": "listsandboxpreviewtokens", + "Description": "Return the tokens of a private preview in the paginated list format, including expired tokens until they are removed. cursor and limit are accepted but not applied yet; all tokens fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied.", + "Language": "http", + "Code": "### List preview tokens\n# @name ListSandboxPreviewTokens\nGET {{host}}/v1/sandboxes/instances/{{sandbox_name}}/previews/{{preview_name}}/tokens?team_id={{team_id}}\u0026cursor={{cursor}}\u0026limit=20\nAuthorization: Bearer {{token}}\nX-Team-Id: {{X-Team-Id}}\nAccept: application/json\n\n## Responses\n# 200\n# Description: Successful operation.\n# Content-Type: application/json\n# 400\n# Description: The preview is public, so it has no tokens. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 401\n# Description: Missing or invalid authentication. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 403\n# Description: Insufficient permissions. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 404\n# Description: Resource not found. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 429\n# Description: Request limit exceeded. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 500\n# Description: Internal server error. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json", + "Format": "http", + "OperationId": "ListSandboxPreviewTokens", + "Setup": null + }, + { + "Order": 16, + "Title": "List sandbox previews", + "Slug": "listsandboxpreviews", + "Description": "Return the previews of the sandbox in the paginated list format. cursor and limit are accepted but not applied yet; all previews fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied.", + "Language": "http", + "Code": "### List sandbox previews\n# @name ListSandboxPreviews\nGET {{host}}/v1/sandboxes/instances/{{sandbox_name}}/previews?team_id={{team_id}}\u0026cursor={{cursor}}\u0026limit=20\nAuthorization: Bearer {{token}}\nX-Team-Id: {{X-Team-Id}}\nAccept: application/json\n\n## Responses\n# 200\n# Description: Successful operation.\n# Content-Type: application/json\n# 401\n# Description: Missing or invalid authentication. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 403\n# Description: Insufficient permissions. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 404\n# Description: Resource not found. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 429\n# Description: Request limit exceeded. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 500\n# Description: Internal server error. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json", + "Format": "http", + "OperationId": "ListSandboxPreviews", + "Setup": null + }, + { + "Order": 17, + "Title": "Update a sandbox preview", + "Slug": "updatesandboxpreview", + "Description": "Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400.", + "Language": "http", + "Code": "### Update a sandbox preview\n# @name UpdateSandboxPreview\nPATCH {{host}}/v1/sandboxes/instances/{{sandbox_name}}/previews/{{preview_name}}?team_id={{team_id}}\nAuthorization: Bearer {{token}}\nX-Team-Id: {{X-Team-Id}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022public\u0022: false,\n \u0022ttl\u0022: \u00227d\u0022\n}\n\n## Responses\n# 200\n# Description: Successful operation.\n# Content-Type: application/json\n# 400\n# Description: Invalid request. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 401\n# Description: Missing or invalid authentication. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 403\n# Description: Insufficient permissions. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 404\n# Description: Resource not found. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 409\n# Description: Resource is currently in use or conflicts with the requested operation. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 429\n# Description: Request limit exceeded. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json\n# 500\n# Description: Internal server error. Returns a JSON error with code, message, and optional details.\n# Content-Type: application/json", + "Format": "http", + "OperationId": "UpdateSandboxPreview", + "Setup": null + }, + { + "Order": 18, "Title": "Create a sandbox", "Slug": "createsandbox", "Description": "Create a sandbox with an optional client-provided name, generated by the server when omitted. The request waits briefly for deployment, then returns the created resource. Deployment may continue after the response; inspect status to determine readiness. Names belonging to failed or terminated sandboxes can be reused; an active sandbox reserves its name. Every field is optional. The server applies image and memory defaults; SDKs should omit fields the caller did not set. A request with no body creates a sandbox from baseten/base-image:latest, the built-in image with the sandbox execution API ready to use, with 4096 MB of memory. It is available directly; no image build, push, or GET /v1/sandboxes/images is needed. Use the returned url to execute commands with your authentication token as a Bearer token, not your Baseten API key.", @@ -111,7 +199,7 @@ "Setup": "This example assumes \u0060using Baseten;\u0060 is in scope and \u0060apiKey\u0060 contains the required credential." }, { - "Order": 11, + "Order": 19, "Title": "Delete a sandbox", "Slug": "deletesandbox", "Description": "Permanently delete the sandbox and its local data asynchronously. The returned resource has status DELETING.", @@ -122,7 +210,7 @@ "Setup": null }, { - "Order": 12, + "Order": 20, "Title": "Get a sandbox", "Slug": "getsandbox", "Description": "Return the sandbox configuration and status.", @@ -133,7 +221,7 @@ "Setup": null }, { - "Order": 13, + "Order": 21, "Title": "Get sandbox configuration", "Slug": "getsandboxconfiguration", "Description": "Return available Carbon-compatible sandbox regions. Configuration is the same for every team, so no team is selected. Only enabled regions supporting Carbon are returned. This describes regional capability, not the runtime selected for a particular team or sandbox. Region configuration is cached for up to 30 seconds.", @@ -144,7 +232,7 @@ "Setup": "This example assumes \u0060using Baseten;\u0060 is in scope and \u0060apiKey\u0060 contains the required credential." }, { - "Order": 14, + "Order": 22, "Title": "List sandboxes", "Slug": "listsandboxes", "Description": "Return a cursor-paginated page of sandboxes. Terminated sandboxes are hidden by default.", @@ -155,7 +243,7 @@ "Setup": "This example assumes \u0060using Baseten;\u0060 is in scope and \u0060apiKey\u0060 contains the required credential." }, { - "Order": 15, + "Order": 23, "Title": "Update a sandbox", "Slug": "updatesandbox", "Description": "Partially update configuration. Omitted fields remain unchanged; supplied arrays and maps replace their previous values. Structured objects update only supplied fields. The name, memory, network, region, image, and ports are immutable after creation. Supplying any of these fields returns 400, including unchanged, empty, or null values.", diff --git a/src/libs/Baseten/openapi.yaml b/src/libs/Baseten/openapi.yaml index 29024fb..65e6289 100644 --- a/src/libs/Baseten/openapi.yaml +++ b/src/libs/Baseten/openapi.yaml @@ -11373,6 +11373,55 @@ } ] }, + "/v1/sandboxes/configuration": { + "get": { + "operationId": "GetSandboxConfiguration", + "summary": "Get sandbox configuration", + "description": "Return available Carbon-compatible sandbox regions. Configuration is the same for every team, so no team is selected. Only enabled regions supporting Carbon are returned. This describes regional capability, not the runtime selected for a particular team or sandbox. Region configuration is cached for up to 30 seconds.", + "tags": [ + "Sandboxes" + ], + "responses": { + "200": { + "description": "Successful operation.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetSandboxConfigurationResponseV1" + }, + "example": { + "regions": [ + { + "name": "us-was-1", + "country": "us", + "continent": "na", + "location": "Washington", + "info_generation": "CARBON" + } + ] + } + } + } + }, + "400": { + "$ref": "#/components/responses/SandboxError400" + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + } + }, "/v1/sandboxes/instances/{sandbox_name}/metrics": { "get": { "operationId": "GetSandboxMetrics", @@ -11529,55 +11578,6 @@ "x-stability": "unstable" } }, - "/v1/sandboxes/configuration": { - "get": { - "operationId": "GetSandboxConfiguration", - "summary": "Get sandbox configuration", - "description": "Return available Carbon-compatible sandbox regions. Configuration is the same for every team, so no team is selected. Only enabled regions supporting Carbon are returned. This describes regional capability, not the runtime selected for a particular team or sandbox. Region configuration is cached for up to 30 seconds.", - "tags": [ - "Sandboxes" - ], - "responses": { - "200": { - "description": "Successful operation.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetSandboxConfigurationResponseV1" - }, - "example": { - "regions": [ - { - "name": "us-was-1", - "country": "us", - "continent": "na", - "location": "Washington", - "info_generation": "CARBON" - } - ] - } - } - } - }, - "400": { - "$ref": "#/components/responses/SandboxError400" - }, - "401": { - "$ref": "#/components/responses/SandboxError401" - }, - "403": { - "$ref": "#/components/responses/SandboxError403" - }, - "429": { - "$ref": "#/components/responses/SandboxError429" - }, - "500": { - "$ref": "#/components/responses/SandboxError500" - } - }, - "x-stability": "unstable" - } - }, "/v1/sandboxes/instances": { "get": { "operationId": "ListSandboxes", @@ -11954,6 +11954,521 @@ "x-stability": "unstable" } }, + "/v1/sandboxes/instances/{sandbox_name}/previews": { + "parameters": [ + { + "$ref": "#/components/parameters/SandboxName" + } + ], + "get": { + "parameters": [ + { + "$ref": "#/components/parameters/TeamId" + }, + { + "$ref": "#/components/parameters/TeamIdHeader" + }, + { + "$ref": "#/components/parameters/Cursor" + }, + { + "$ref": "#/components/parameters/Limit" + } + ], + "operationId": "ListSandboxPreviews", + "summary": "List sandbox previews", + "description": "Return the previews of the sandbox in the paginated list format. cursor and limit are accepted but not applied yet; all previews fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied.", + "tags": [ + "Previews" + ], + "responses": { + "200": { + "description": "Successful operation.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListSandboxPreviewsResponseV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/SandboxPreviewsList" + } + } + } + } + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "404": { + "$ref": "#/components/responses/SandboxError404" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + }, + "post": { + "parameters": [ + { + "$ref": "#/components/parameters/TeamId" + }, + { + "$ref": "#/components/parameters/TeamIdHeader" + } + ], + "operationId": "CreateSandboxPreview", + "summary": "Create a sandbox preview", + "description": "Expose a port of the sandbox on an HTTPS URL. A public preview is reachable by anyone with the URL. A private preview requires a preview token, created with the tokens endpoint and sent as the bl_preview_token query parameter; the first request sets a bl_preview_token cookie so a browser can keep navigating without it. Port 80 and the sandbox's reserved system ports are rejected, and port 443 must stay private. Without a name, the name is generated from the sandbox name and port, or is public- or private- when create_if_not_exists is true.", + "tags": [ + "Previews" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateSandboxPreviewRequestV1" + }, + "examples": { + "public": { + "$ref": "#/components/examples/CreateSandboxPreviewPublic" + }, + "private": { + "$ref": "#/components/examples/CreateSandboxPreviewPrivate" + } + } + } + } + }, + "responses": { + "201": { + "description": "Preview created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SandboxPreviewV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/SandboxPreviewReady" + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/SandboxError400" + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "404": { + "$ref": "#/components/responses/SandboxError404" + }, + "409": { + "$ref": "#/components/responses/SandboxError409" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + } + }, + "/v1/sandboxes/instances/{sandbox_name}/previews/{preview_name}": { + "parameters": [ + { + "$ref": "#/components/parameters/SandboxName" + }, + { + "$ref": "#/components/parameters/PreviewName" + } + ], + "get": { + "parameters": [ + { + "$ref": "#/components/parameters/TeamId" + }, + { + "$ref": "#/components/parameters/TeamIdHeader" + }, + { + "name": "show_secrets", + "in": "query", + "description": "Reveal request header values for workspace administrators, for example to change one header and send the full set back in a PATCH. Defaults to false. Callers without the admin role receive masked values even when true.", + "schema": { + "type": "boolean", + "default": false + } + } + ], + "operationId": "GetSandboxPreview", + "summary": "Get a sandbox preview", + "description": "Return the preview configuration, URL and status.", + "tags": [ + "Previews" + ], + "responses": { + "200": { + "description": "Successful operation.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SandboxPreviewV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/SandboxPreviewReady" + } + } + } + } + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "404": { + "$ref": "#/components/responses/SandboxError404" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + }, + "patch": { + "parameters": [ + { + "$ref": "#/components/parameters/TeamId" + }, + { + "$ref": "#/components/parameters/TeamIdHeader" + } + ], + "operationId": "UpdateSandboxPreview", + "summary": "Update a sandbox preview", + "description": "Partially update the preview. Omitted fields remain unchanged; supplied header maps replace their previous values. The URL does not change. Setting ttl or expires_at replaces any previous expiration and restarts it from now. The name and port are immutable; supplying either returns 400.", + "tags": [ + "Previews" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateSandboxPreviewRequestV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/UpdateSandboxPreview" + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful operation.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SandboxPreviewV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/SandboxPreviewReady" + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/SandboxError400" + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "404": { + "$ref": "#/components/responses/SandboxError404" + }, + "409": { + "$ref": "#/components/responses/SandboxError409" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + }, + "delete": { + "parameters": [ + { + "$ref": "#/components/parameters/TeamId" + }, + { + "$ref": "#/components/parameters/TeamIdHeader" + } + ], + "operationId": "DeleteSandboxPreview", + "summary": "Delete a sandbox preview", + "description": "Delete the preview and revoke its tokens. The URL stops serving immediately. Return the deleted preview, with status TERMINATED, or DELETING while a preview with many tokens finishes in the background.", + "tags": [ + "Previews" + ], + "responses": { + "200": { + "description": "Successful operation.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SandboxPreviewV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/SandboxPreviewDeleted" + } + } + } + } + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "404": { + "$ref": "#/components/responses/SandboxError404" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + } + }, + "/v1/sandboxes/instances/{sandbox_name}/previews/{preview_name}/tokens": { + "parameters": [ + { + "$ref": "#/components/parameters/SandboxName" + }, + { + "$ref": "#/components/parameters/PreviewName" + } + ], + "get": { + "parameters": [ + { + "$ref": "#/components/parameters/TeamId" + }, + { + "$ref": "#/components/parameters/TeamIdHeader" + }, + { + "$ref": "#/components/parameters/Cursor" + }, + { + "$ref": "#/components/parameters/Limit" + } + ], + "operationId": "ListSandboxPreviewTokens", + "summary": "List preview tokens", + "description": "Return the tokens of a private preview in the paginated list format, including expired tokens until they are removed. cursor and limit are accepted but not applied yet; all tokens fit on one page, so has_more is false. Follow pagination.cursor while has_more is true to stay compatible when they are applied.", + "tags": [ + "Previews" + ], + "responses": { + "200": { + "description": "Successful operation.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ListSandboxPreviewTokensResponseV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/SandboxPreviewTokensList" + } + } + } + } + }, + "400": { + "description": "The preview is public, so it has no tokens. Returns a JSON error with code, message, and optional details.", + "content": { + "application/json": { + "example": { + "code": "INVALID_REQUEST", + "message": "Public preview cannot have tokens." + } + } + } + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "404": { + "$ref": "#/components/responses/SandboxError404" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + }, + "post": { + "parameters": [ + { + "$ref": "#/components/parameters/TeamId" + }, + { + "$ref": "#/components/parameters/TeamIdHeader" + } + ], + "operationId": "CreateSandboxPreviewToken", + "summary": "Create a preview token", + "description": "Create a token granting access to a private preview until expires_at. Append it to the preview URL as ?bl_preview_token=.", + "tags": [ + "Previews" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateSandboxPreviewTokenRequestV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/CreateSandboxPreviewToken" + } + } + } + } + }, + "responses": { + "201": { + "description": "Token created.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SandboxPreviewTokenV1" + }, + "examples": { + "complete": { + "$ref": "#/components/examples/SandboxPreviewToken" + } + } + } + } + }, + "400": { + "$ref": "#/components/responses/SandboxError400" + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "404": { + "$ref": "#/components/responses/SandboxError404" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + } + }, + "/v1/sandboxes/instances/{sandbox_name}/previews/{preview_name}/tokens/{token_name}": { + "parameters": [ + { + "$ref": "#/components/parameters/SandboxName" + }, + { + "$ref": "#/components/parameters/PreviewName" + }, + { + "$ref": "#/components/parameters/PreviewTokenName" + } + ], + "delete": { + "parameters": [ + { + "$ref": "#/components/parameters/TeamId" + }, + { + "$ref": "#/components/parameters/TeamIdHeader" + } + ], + "operationId": "DeleteSandboxPreviewToken", + "summary": "Delete a preview token", + "description": "Revoke the token. Requests using it are rejected immediately.", + "tags": [ + "Previews" + ], + "responses": { + "204": { + "description": "Token deleted." + }, + "401": { + "$ref": "#/components/responses/SandboxError401" + }, + "403": { + "$ref": "#/components/responses/SandboxError403" + }, + "404": { + "$ref": "#/components/responses/SandboxError404" + }, + "429": { + "$ref": "#/components/responses/SandboxError429" + }, + "500": { + "$ref": "#/components/responses/SandboxError500" + } + }, + "x-stability": "unstable" + } + }, "/v1/sandboxes/library_images": { "get": { "operationId": "ListSandboxLibraryImages", @@ -24390,7 +24905,7 @@ } ], "default": null, - "description": "Error message if the training job failed.", + "description": "Error message if the training job failed. While the job is pending, a hint when switching it to spot capacity would let it start sooner.", "title": "Error Message" }, "instance_type": { @@ -39142,6 +39657,278 @@ "deleted": 3, "message": "Removed 3 unused image versions. Image versions used by active sandboxes were retained." } + }, + "SandboxPreviewStatusV1": { + "type": "string", + "description": "Preview status, always uppercase.", + "enum": [ + "DEPLOYING", + "DEPLOYED", + "FAILED", + "DELETING", + "TERMINATED" + ], + "readOnly": true, + "example": "DEPLOYED" + }, + "SandboxPreviewTtlV1": { + "type": "string", + "description": "Lifetime counted from the request, using seconds, minutes, hours or composite durations such as 1h30m. Whole days are also supported, for example 7d; days cannot be combined with other units. The preview is deleted when it elapses.", + "pattern": "^([0-9]+d|(([0-9]+(\\.[0-9]*)?|\\.[0-9]+)(ns|us|\u00b5s|\u03bcs|ms|s|m|h))+)$", + "example": "24h" + }, + "SandboxPreviewHeadersV1": { + "type": "object", + "description": "HTTP headers as name-value pairs.", + "additionalProperties": { + "type": "string" + }, + "example": { + "Access-Control-Allow-Origin": "*" + } + }, + "SandboxPreviewConfigurationV1": { + "type": "object", + "description": "Mutable preview configuration. ttl and expires_at are mutually exclusive; supplying both returns 400.", + "properties": { + "public": { + "type": "boolean", + "description": "Whether the URL is reachable without a preview token. Defaults to false.", + "default": false, + "example": true + }, + "response_headers": { + "description": "Headers added to every response served by the preview, for example CORS headers.", + "allOf": [ + { + "$ref": "#/components/schemas/SandboxPreviewHeadersV1" + } + ] + }, + "request_headers": { + "description": "Headers added to every request forwarded to the sandbox, for example an Authorization header expected by the application. Responses return each name with the value \"****\", except a GET with show_secrets=true by a workspace administrator. Sending \"****\" back as a value returns 400. A PATCH replaces the whole set.", + "allOf": [ + { + "$ref": "#/components/schemas/SandboxPreviewHeadersV1" + } + ], + "example": { + "Authorization": "Bearer app-internal-token" + } + }, + "ttl": { + "$ref": "#/components/schemas/SandboxPreviewTtlV1" + }, + "expires_at": { + "type": "string", + "format": "date-time", + "description": "Time at which the preview is deleted. Must be in the future.", + "example": "2026-10-19T12:00:00Z" + } + } + }, + "CreateSandboxPreviewRequestV1": { + "description": "Preview to create. Only port is required.", + "allOf": [ + { + "$ref": "#/components/schemas/SandboxPreviewConfigurationV1" + }, + { + "type": "object", + "properties": { + "create_if_not_exists": { + "type": "boolean", + "description": "When true, return the existing preview with this name instead of failing with a conflict. Without name, the name is public- or private-, so the same port and visibility return the same preview. Existing configuration is preserved. Defaults to false when omitted." + }, + "name": { + "type": "string", + "description": "Preview name, unique within the sandbox. When omitted, generated from the sandbox name and port, or public- or private- when create_if_not_exists is true.", + "minLength": 1, + "maxLength": 49, + "pattern": "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$", + "example": "web" + }, + "port": { + "type": "integer", + "description": "Sandbox port to expose.", + "minimum": 1, + "maximum": 65535, + "example": 3000 + } + }, + "required": [ + "port" + ] + } + ] + }, + "UpdateSandboxPreviewRequestV1": { + "description": "Preview fields to change. name and port cannot be changed.", + "allOf": [ + { + "$ref": "#/components/schemas/SandboxPreviewConfigurationV1" + } + ] + }, + "SandboxPreviewV1": { + "description": "Sandbox preview with configuration and server-managed fields at the root.", + "allOf": [ + { + "$ref": "#/components/schemas/SandboxPreviewConfigurationV1" + }, + { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Preview name, used in preview_name path parameters.", + "readOnly": true, + "example": "web" + }, + "port": { + "type": "integer", + "description": "Exposed sandbox port.", + "readOnly": true, + "example": 3000 + }, + "url": { + "type": "string", + "format": "uri", + "description": "HTTPS URL serving the port, including the region label. Use this exact URL. Requests to a private preview need a token.", + "readOnly": true, + "example": "https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co" + }, + "status": { + "$ref": "#/components/schemas/SandboxPreviewStatusV1" + }, + "region": { + "type": "string", + "description": "Region serving the preview, the sandbox's region.", + "readOnly": true, + "example": "us-pdx-1" + }, + "created_at": { + "type": "string", + "format": "date-time", + "readOnly": true, + "example": "2026-10-12T12:00:00Z" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "readOnly": true, + "example": "2026-10-12T12:00:00Z" + }, + "created_by": { + "type": "string", + "readOnly": true, + "example": "sandbox-automation" + }, + "updated_by": { + "type": "string", + "readOnly": true, + "example": "sandbox-automation" + } + }, + "required": [ + "name", + "port", + "url", + "status", + "public" + ] + } + ] + }, + "ListSandboxPreviewsResponseV1": { + "type": "object", + "description": "One page of previews of a sandbox.", + "properties": { + "items": { + "type": "array", + "description": "Resources on this page.", + "items": { + "$ref": "#/components/schemas/SandboxPreviewV1" + } + }, + "pagination": { + "$ref": "#/components/schemas/SandboxApiPaginationV1" + } + }, + "required": [ + "items", + "pagination" + ] + }, + "CreateSandboxPreviewTokenRequestV1": { + "type": "object", + "properties": { + "create_if_not_exists": { + "type": "boolean", + "description": "When true, return an existing unexpired token of this preview that stays valid at least until expires_at instead of creating a new one. Defaults to false when omitted." + }, + "expires_at": { + "type": "string", + "format": "date-time", + "description": "Time at which the token stops working. Must be in the future.", + "example": "2026-10-13T12:00:00Z" + } + }, + "required": [ + "expires_at" + ] + }, + "SandboxPreviewTokenV1": { + "type": "object", + "description": "Access token for a private preview.", + "properties": { + "name": { + "type": "string", + "description": "Token name, used in token_name path parameters.", + "example": "7f3k2m9q1x8c4v6b0n5z" + }, + "token": { + "type": "string", + "description": "Value to send as the bl_preview_token query parameter.", + "example": "7f3k2m9q1x8c4v6b0n5z" + }, + "expires_at": { + "type": "string", + "format": "date-time", + "example": "2026-10-13T12:00:00Z" + }, + "expired": { + "type": "boolean", + "description": "Whether expires_at has passed.", + "example": false + } + }, + "required": [ + "name", + "token", + "expires_at", + "expired" + ] + }, + "ListSandboxPreviewTokensResponseV1": { + "type": "object", + "description": "One page of tokens of a preview.", + "properties": { + "items": { + "type": "array", + "description": "Resources on this page.", + "items": { + "$ref": "#/components/schemas/SandboxPreviewTokenV1" + } + }, + "pagination": { + "$ref": "#/components/schemas/SandboxApiPaginationV1" + } + }, + "required": [ + "items", + "pagination" + ] } }, "parameters": { @@ -39452,6 +40239,28 @@ "example": "baseten-api-review-0916" } }, + "PreviewName": { + "name": "preview_name", + "in": "path", + "required": true, + "description": "Preview name returned by creation.", + "schema": { + "type": "string", + "minLength": 1, + "example": "web" + } + }, + "PreviewTokenName": { + "name": "token_name", + "in": "path", + "required": true, + "description": "Token name returned by creation.", + "schema": { + "type": "string", + "minLength": 1, + "example": "7f3k2m9q1x8c4v6b0n5z" + } + }, "SandboxImageName": { "name": "image_name", "in": "path", @@ -40357,6 +41166,115 @@ "deleted": 3, "message": "Removed 3 unused image versions. Image versions used by active sandboxes were retained." } + }, + "CreateSandboxPreviewPublic": { + "summary": "Public preview of a web server", + "value": { + "name": "web", + "port": 3000, + "public": true, + "response_headers": { + "Access-Control-Allow-Origin": "*" + } + } + }, + "CreateSandboxPreviewPrivate": { + "summary": "Private preview deleted after one day", + "value": { + "port": 8080, + "ttl": "24h" + } + }, + "UpdateSandboxPreview": { + "summary": "Make a preview private and extend it", + "value": { + "public": false, + "ttl": "7d" + } + }, + "SandboxPreviewReady": { + "summary": "Public preview", + "value": { + "name": "web", + "port": 3000, + "public": true, + "url": "https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co", + "status": "DEPLOYED", + "region": "us-pdx-1", + "response_headers": { + "Access-Control-Allow-Origin": "*" + }, + "created_at": "2026-10-12T12:00:00Z", + "updated_at": "2026-10-12T12:00:00Z", + "created_by": "sandbox-automation", + "updated_by": "sandbox-automation" + } + }, + "SandboxPreviewDeleted": { + "summary": "Deleted preview", + "value": { + "name": "web", + "port": 3000, + "public": true, + "url": "https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co", + "status": "TERMINATED", + "region": "us-pdx-1", + "created_at": "2026-10-12T12:00:00Z", + "updated_at": "2026-10-12T12:00:00Z", + "created_by": "sandbox-automation", + "updated_by": "sandbox-automation" + } + }, + "SandboxPreviewsList": { + "summary": "Previews of a sandbox", + "value": { + "items": [ + { + "name": "web", + "port": 3000, + "public": true, + "url": "https://a1b2c3d4e5f6g7h8.us-pdx-1.preview.b10.co", + "status": "DEPLOYED", + "region": "us-pdx-1", + "created_at": "2026-10-12T12:00:00Z", + "updated_at": "2026-10-12T12:00:00Z" + } + ], + "pagination": { + "has_more": false + } + } + }, + "CreateSandboxPreviewToken": { + "summary": "Token valid for one day", + "value": { + "expires_at": "2026-10-13T12:00:00Z" + } + }, + "SandboxPreviewToken": { + "summary": "Created token", + "value": { + "name": "7f3k2m9q1x8c4v6b0n5z", + "token": "7f3k2m9q1x8c4v6b0n5z", + "expires_at": "2026-10-13T12:00:00Z", + "expired": false + } + }, + "SandboxPreviewTokensList": { + "summary": "Tokens of a preview", + "value": { + "items": [ + { + "name": "7f3k2m9q1x8c4v6b0n5z", + "token": "7f3k2m9q1x8c4v6b0n5z", + "expires_at": "2026-10-13T12:00:00Z", + "expired": false + } + ], + "pagination": { + "has_more": false + } + } } } }