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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static partial class CreateRoutesCommandApiCommand
private static Option<string?> TeamId { get; } = new(
name: @"--team-id")
{
Description = @"Identifier of the team that owns the route. When omitted, uses your organization's default team.",
Description = @"Identifier of the team that owns the route.",
};

private static Option<string?> DisplayName { get; } = new(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace Baseten.CLI.Commands;

internal static partial class CreateRoutesConnectionsCommandApiCommand
{
private static Option<string?> TeamId { get; } = new(
name: @"--team-id")
{
Description = @"Identifier of the team that owns the connection.",
};

private static Option<global::Baseten.Config2> Config { get; } = new(
name: @"--config")
{
Description = @"Provider the connection authenticates with, and the team secret holding its API key.",
Required = true,
};
private static Option<string?> Input { get; } = new(@"--input")
{
Description = "Load request JSON from a file path, '-' for stdin, or an inline JSON object/array string.",
};

private static Option<string?> RequestJson { get; } = new(@"--request-json")
{
Description = "Request body as JSON.",
Hidden = true,
};

private static Option<string?> 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.RouteConnectionV1 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<string, CliFormatHint>(StringComparer.OrdinalIgnoreCase)
{
};
CustomizeResponseFormatHints(hints);
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.RouteConnectionV1 value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create(string? commandName = null)
{
var command = new Command(commandName ?? @"create-routes-connections", @"Creates a connection
Creates a connection from the team to an upstream provider.");
command.Options.Add(TeamId);
command.Options.Add(Config);
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<global::Baseten.CreateRouteConnectionRequestV1>(
parseResult,
Input,
RequestJson,
RequestFile,
global::Baseten.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var teamId = CliRuntime.WasSpecified(parseResult, TeamId) ? parseResult.GetValue(TeamId) : (__requestBase is { } __TeamIdBaseValue ? __TeamIdBaseValue.TeamId : default);
var config = parseResult.GetRequiredValue(Config);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.CreateRoutesConnectionsAsync(
teamId: teamId,
config: config,
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;
}
}
4 changes: 4 additions & 0 deletions src/cli/Baseten.CLI/Commands/DefaultApiGroupCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static Command Create()
command.Subcommands.Add(CreateModelsByModelIdEnvironmentsByEnvNameResumePromotionCommandApiCommand.Create());
command.Subcommands.Add(CreatePrepareModelUploadCommandApiCommand.Create());
command.Subcommands.Add(CreateRoutesCommandApiCommand.Create());
command.Subcommands.Add(CreateRoutesConnectionsCommandApiCommand.Create());
command.Subcommands.Add(CreateSecretsCommandApiCommand.Create());
command.Subcommands.Add(CreateTeamsByTeamIdApiKeysCommandApiCommand.Create());
command.Subcommands.Add(CreateTeamsByTeamIdLlmModelsCommandApiCommand.Create());
Expand Down Expand Up @@ -93,6 +94,7 @@ public static Command Create()
command.Subcommands.Add(DeleteModelsByModelIdDeploymentsByDeploymentIdReplicasByReplicaIdCommandApiCommand.Create());
command.Subcommands.Add(DeleteModelsByModelIdEnvironmentsByEnvNameCommandApiCommand.Create());
command.Subcommands.Add(DeleteRoutesByRouteIdCommandApiCommand.Create());
command.Subcommands.Add(DeleteRoutesConnectionsByConnectionIdCommandApiCommand.Create());
command.Subcommands.Add(DeleteSecretsBySecretNameCommandApiCommand.Create());
command.Subcommands.Add(DeleteTeamsByTeamIdSecretsBySecretNameCommandApiCommand.Create());
command.Subcommands.Add(DeleteTrainingProjectsByTrainingProjectIdCommandApiCommand.Create());
Expand All @@ -115,6 +117,7 @@ public static Command Create()
command.Subcommands.Add(EditModelsByModelIdDeploymentsProductionAutoscalingSettingsCommandApiCommand.Create());
command.Subcommands.Add(EditModelsByModelIdEnvironmentsByEnvNameCommandApiCommand.Create());
command.Subcommands.Add(EditRoutesByRouteIdCommandApiCommand.Create());
command.Subcommands.Add(EditRoutesConnectionsByConnectionIdCommandApiCommand.Create());
command.Subcommands.Add(EditRoutesSettingsTeamsByTeamIdCommandApiCommand.Create());
command.Subcommands.Add(EditRoutesSettingsUsersByUserIdCommandApiCommand.Create());
command.Subcommands.Add(EditTeamsByTeamIdEnvironmentGroupsByEnvNameCommandApiCommand.Create());
Expand Down Expand Up @@ -189,6 +192,7 @@ public static Command Create()
command.Subcommands.Add(GetRegionsCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesByRouteIdCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesConnectionsCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesSettingsTeamsByTeamIdCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesSettingsUsersByUserIdCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesUsageCommandApiCommand.Create());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace Baseten.CLI.Commands;

internal static partial class DeleteRoutesConnectionsByConnectionIdCommandApiCommand
{
private static Argument<string> ConnectionId { get; } = new(
name: @"connection-id")
{
Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.",
};

private static string FormatResponse(ParseResult parseResult, global::Baseten.RouteConnectionTombstoneV1 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<string, CliFormatHint>(StringComparer.OrdinalIgnoreCase)
{
};
CustomizeResponseFormatHints(hints);
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.RouteConnectionTombstoneV1 value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create(string? commandName = null)
{
var command = new Command(commandName ?? @"delete-routes-connections-by-connection-id", @"Deletes a connection
Deletes the connection. The team secret it points at is left in place.");
command.Arguments.Add(ConnectionId);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var connectionId = parseResult.GetRequiredValue(ConnectionId);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.DeleteRoutesConnectionsByConnectionIdAsync(
connectionId: connectionId,
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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace Baseten.CLI.Commands;

internal static partial class EditRoutesConnectionsByConnectionIdCommandApiCommand
{
private static Argument<string> ConnectionId { get; } = new(
name: @"connection-id")
{
Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.",
};

private static Option<global::Baseten.Config3> Config { get; } = new(
name: @"--config")
{
Description = @"Connection fields to change. The provider must match the connection and is immutable.",
Required = true,
};

private static string FormatResponse(ParseResult parseResult, global::Baseten.RouteConnectionV1 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<string, CliFormatHint>(StringComparer.OrdinalIgnoreCase)
{
};
CustomizeResponseFormatHints(hints);
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, global::Baseten.RouteConnectionV1 value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create(string? commandName = null)
{
var command = new Command(commandName ?? @"edit-routes-connections-by-connection-id", @"Updates a connection
Updates the connection's fields. The provider and owning team are immutable; point the connection at a new team secret to change its API key, or rotate the key itself by updating the secret.");
command.Arguments.Add(ConnectionId);
command.Options.Add(Config);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var connectionId = parseResult.GetRequiredValue(ConnectionId);
var config = parseResult.GetRequiredValue(Config);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.EditRoutesConnectionsByConnectionIdAsync(
connectionId: connectionId,
config: config,
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;
}
}
4 changes: 2 additions & 2 deletions src/cli/Baseten.CLI/Commands/GetRoutesCommandApiCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static partial class GetRoutesCommandApiCommand
private static Option<string?> TeamId { get; } = new(
name: @"--team-id")
{
Description = @"Filter by owning team ID. Preserved by the cursor; if repeated, must match the original filter.",
Description = @"Identifier of the team whose routes to list.",
};

private static Option<string?> NameOption { get; } = new(
Expand Down Expand Up @@ -56,7 +56,7 @@ private static string FormatResponse(ParseResult parseResult, global::Baseten.Ro
public static Command Create(string? commandName = null)
{
var command = new Command(commandName ?? @"get-routes", @"Lists routes
Lists routes you can invoke, newest first, optionally filtered by team and exact name.");
Lists routes you can invoke in the team, newest first, optionally filtered by exact name.");
command.Options.Add(Cursor);
command.Options.Add(Limit);
command.Options.Add(TeamId);
Expand Down
Loading
Loading