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
3 changes: 3 additions & 0 deletions src/cli/Baseten.CLI/Commands/DefaultApiGroupCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public static Command Create()
command.Subcommands.Add(EditRoutesByRouteIdCommandApiCommand.Create());
command.Subcommands.Add(EditRoutesConnectionsByConnectionIdCommandApiCommand.Create());
command.Subcommands.Add(EditRoutesSettingsTeamsByTeamIdCommandApiCommand.Create());
command.Subcommands.Add(EditRoutesSettingsTeamsByTeamIdUsersByUserIdCommandApiCommand.Create());
command.Subcommands.Add(EditRoutesSettingsUsersByUserIdCommandApiCommand.Create());
command.Subcommands.Add(EditTeamsByTeamIdEnvironmentGroupsByEnvNameCommandApiCommand.Create());
command.Subcommands.Add(EditTrainingCapacityCommandApiCommand.Create());
Expand Down Expand Up @@ -194,6 +195,8 @@ public static Command Create()
command.Subcommands.Add(GetRoutesByRouteIdCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesConnectionsCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesSettingsTeamsByTeamIdCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesSettingsTeamsByTeamIdUsersCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesSettingsTeamsByTeamIdUsersByUserIdCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesSettingsUsersByUserIdCommandApiCommand.Create());
command.Subcommands.Add(GetRoutesUsageCommandApiCommand.Create());
command.Subcommands.Add(GetSecretsCommandApiCommand.Create());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace Baseten.CLI.Commands;

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

private static Argument<string> UserId { get; } = new(
name: @"user-id")
{
Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.",
};
private static readonly UpdateRouteSpendLimitSettingV1OptionSet SpendLimitOptions = UpdateRouteSpendLimitSettingV1OptionSet.Create(@"spend-limit");
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.RouteTeamUserSettingsV1 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.RouteTeamUserSettingsV1 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-settings-teams-by-team-id-users-by-user-id", @"Updates a user's route settings in a team
Changes only the fields in the request. Once the user's metered spend in the team in a month reaches the spend limit, requests with Routes keys they created in the team are rejected until the limit is raised or the next month starts. Spend is metered every 15 minutes and can lag, so a user can go over the limit. Requires organization admin.");
command.Arguments.Add(TeamId);
command.Arguments.Add(UserId); command.Options.Add(SpendLimitOptions.UserMonthlyLimitUsd);
command.Options.Add(SpendLimitOptions.MonthOverrideUsd);
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.UpdateRouteUserSettingsRequestV1>(
parseResult,
Input,
RequestJson,
RequestFile,
global::Baseten.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var teamId = parseResult.GetRequiredValue(TeamId);
var userId = parseResult.GetRequiredValue(UserId);

var __SpendLimitBase = __requestBase is { } __SpendLimitBaseValue ? __SpendLimitBaseValue.SpendLimit : default; var spendLimitUserMonthlyLimitUsd = CliRuntime.WasSpecified(parseResult, SpendLimitOptions.UserMonthlyLimitUsd) ? parseResult.GetValue(SpendLimitOptions.UserMonthlyLimitUsd) : (__SpendLimitBase is { } __SpendLimituserMonthlyLimitUsdBaseValue ? __SpendLimituserMonthlyLimitUsdBaseValue.UserMonthlyLimitUsd : default);
var spendLimitMonthOverrideUsd = CliRuntime.WasSpecified(parseResult, SpendLimitOptions.MonthOverrideUsd) ? parseResult.GetValue(SpendLimitOptions.MonthOverrideUsd) : (__SpendLimitBase is { } __SpendLimitmonthOverrideUsdBaseValue ? __SpendLimitmonthOverrideUsdBaseValue.MonthOverrideUsd : default);
var __SpendLimitSpecified = CliRuntime.WasSpecified(parseResult, SpendLimitOptions.UserMonthlyLimitUsd) || CliRuntime.WasSpecified(parseResult, SpendLimitOptions.MonthOverrideUsd);
var spendLimit =
__SpendLimitSpecified || __SpendLimitBase is not null
? new global::Baseten.UpdateRouteSpendLimitSettingV1
{
UserMonthlyLimitUsd = spendLimitUserMonthlyLimitUsd,
MonthOverrideUsd = spendLimitMonthOverrideUsd,

}
: __SpendLimitBase;
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.EditRoutesSettingsTeamsByTeamIdUsersByUserIdAsync(
teamId: teamId,
userId: userId,
spendLimit: spendLimit,
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
Expand Up @@ -12,12 +12,7 @@ internal static partial class EditRoutesSettingsUsersByUserIdCommandApiCommand
{
Description = @"This is a missing parameter that was added automatically. Please check the OpenAPI spec.",
};

private static Option<global::Baseten.UpdateRouteSpendLimitSettingV1?> SpendLimit { get; } = new(
name: @"--spend-limit")
{
Description = @"Spend limit fields to change. Pass null to remove the user's limit; omit to leave it unchanged.",
};
private static readonly UpdateRouteSpendLimitSettingV1OptionSet SpendLimitOptions = UpdateRouteSpendLimitSettingV1OptionSet.Create(@"spend-limit");
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.",
Expand Down Expand Up @@ -60,9 +55,9 @@ private static string FormatResponse(ParseResult parseResult, global::Baseten.Ro
public static Command Create(string? commandName = null)
{
var command = new Command(commandName ?? @"edit-routes-settings-users-by-user-id", @"Updates a user's route settings
Changes only the fields in the request. Once the user's metered spend in a month reaches the spend limit, requests with Routes keys they created are rejected until the limit is raised or the next month starts. Spend is metered every 15 minutes and can lag, so a user can go over the limit. The user's own limit supersedes their team's per-member limit.");
command.Arguments.Add(UserId);
command.Options.Add(SpendLimit);
Changes only the fields in the request. Once the user's metered spend in a team in a month reaches the spend limit, requests with Routes keys they created in that team are rejected until the limit is raised or the next month starts. Spend is metered every 15 minutes and can lag, so a user can go over the limit. The user's own limit supersedes their team's per-member limit. The limit is set in the only team the user has Code spend in this month, else in their only team; the request fails when there is none.");
command.Arguments.Add(UserId); command.Options.Add(SpendLimitOptions.UserMonthlyLimitUsd);
command.Options.Add(SpendLimitOptions.MonthOverrideUsd);
command.Options.Add(Input);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
Expand All @@ -89,7 +84,19 @@ await CliRuntime.RunAsync(async () =>
global::Baseten.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var userId = parseResult.GetRequiredValue(UserId);
var spendLimit = CliRuntime.WasSpecified(parseResult, SpendLimit) ? parseResult.GetValue(SpendLimit) : (__requestBase is { } __SpendLimitBaseValue ? __SpendLimitBaseValue.SpendLimit : default);

var __SpendLimitBase = __requestBase is { } __SpendLimitBaseValue ? __SpendLimitBaseValue.SpendLimit : default; var spendLimitUserMonthlyLimitUsd = CliRuntime.WasSpecified(parseResult, SpendLimitOptions.UserMonthlyLimitUsd) ? parseResult.GetValue(SpendLimitOptions.UserMonthlyLimitUsd) : (__SpendLimitBase is { } __SpendLimituserMonthlyLimitUsdBaseValue ? __SpendLimituserMonthlyLimitUsdBaseValue.UserMonthlyLimitUsd : default);
var spendLimitMonthOverrideUsd = CliRuntime.WasSpecified(parseResult, SpendLimitOptions.MonthOverrideUsd) ? parseResult.GetValue(SpendLimitOptions.MonthOverrideUsd) : (__SpendLimitBase is { } __SpendLimitmonthOverrideUsdBaseValue ? __SpendLimitmonthOverrideUsdBaseValue.MonthOverrideUsd : default);
var __SpendLimitSpecified = CliRuntime.WasSpecified(parseResult, SpendLimitOptions.UserMonthlyLimitUsd) || CliRuntime.WasSpecified(parseResult, SpendLimitOptions.MonthOverrideUsd);
var spendLimit =
__SpendLimitSpecified || __SpendLimitBase is not null
? new global::Baseten.UpdateRouteSpendLimitSettingV1
{
UserMonthlyLimitUsd = spendLimitUserMonthlyLimitUsd,
MonthOverrideUsd = spendLimitMonthOverrideUsd,

}
: __SpendLimitBase;
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace Baseten.CLI.Commands;

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

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

private static string FormatResponse(ParseResult parseResult, global::Baseten.RouteTeamUserSettingsV1 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.RouteTeamUserSettingsV1 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 ?? @"get-routes-settings-teams-by-team-id-users-by-user-id", @"Gets a user's route settings in a team
Returns the user's spend limit for Baseten Code in the team, their spend in the team this month, and whether that spend reached the limit. Members can read their own settings; organization admins can read anyone's.");
command.Arguments.Add(TeamId);
command.Arguments.Add(UserId);


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


var response = await client.GetRoutesSettingsTeamsByTeamIdUsersByUserIdAsync(
teamId: teamId,
userId: userId,
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;
}
}
Loading
Loading