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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static Command Create()
command.Subcommands.Add(ModelRouterEditRoutersByIdCommandApiCommand.Create());
command.Subcommands.Add(ModelRouterGetRoutersCommandApiCommand.Create());
command.Subcommands.Add(ModelRouterGetRoutersByIdCommandApiCommand.Create());
command.Subcommands.Add(ModelRouterGetRoutersByIdRequestsCommandApiCommand.Create());
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,32 @@ internal static partial class ModelRouterCreateGenerateAudioCommandApiCommand
Required = true,
};

private static Option<bool?> DryRun { get; } = CliRuntime.CreateNullableBoolOption(
name: @"--dry-run",
description: @"When true, run the full routing pipeline and return the decision and estimated cost without generating. No task is created, nothing is billed, and no asset is produced.");

private static Option<global::Runway.CreateGenerateAudioRequestInput> InputOption { get; } = new(
name: @"--input")
{
Description = @"Model-agnostic audio generation input. The router selects a model and maps these options to it.",
Required = true,
};
private static Option<string?> RequestInput { get; } = new(@"--request-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::Runway.CreateGenerateAudioResponse value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
Expand Down Expand Up @@ -54,21 +74,44 @@ public static Command Create()
Start an audio generation task using a saved Model Router config instead of naming a model. Set input.type to speech to speak promptText verbatim, or audio to generate audio described by promptText.");
command.Options.Add(XRunwayVersion);
command.Options.Add(ConfigId);
command.Options.Add(DryRun);
command.Options.Add(InputOption);

command.Options.Add(RequestInput);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
command.Validators.Add(result =>
{
var hasInput = result.GetResult(RequestInput) 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 --request-input, --request-json, or --request-file.");
}
});

command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync<global::Runway.CreateGenerateAudioRequest>(
parseResult,
RequestInput,
RequestJson,
RequestFile,
global::Runway.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var xRunwayVersion = parseResult.GetRequiredValue(XRunwayVersion);
var configId = parseResult.GetRequiredValue(ConfigId);
var dryRun = CliRuntime.WasSpecified(parseResult, DryRun) ? parseResult.GetValue(DryRun) : (__requestBase is { } __DryRunBaseValue ? __DryRunBaseValue.DryRun : default);
var input = parseResult.GetRequiredValue(InputOption);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.ModelRouter.CreateGenerateAudioAsync(
xRunwayVersion: xRunwayVersion,
configId: configId,
dryRun: dryRun,
input: input,
cancellationToken: cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,32 @@ internal static partial class ModelRouterCreateGenerateImageCommandApiCommand
Required = true,
};

private static Option<bool?> DryRun { get; } = CliRuntime.CreateNullableBoolOption(
name: @"--dry-run",
description: @"When true, run the full routing pipeline and return the decision and estimated cost without generating. No task is created, nothing is billed, and no asset is produced.");

private static Option<global::Runway.CreateGenerateImageRequestInput> InputOption { get; } = new(
name: @"--input")
{
Description = @"Model-agnostic image generation input. The router selects a model and maps these options to it.",
Required = true,
};
private static Option<string?> RequestInput { get; } = new(@"--request-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::Runway.CreateGenerateImageResponse value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
Expand Down Expand Up @@ -54,21 +74,44 @@ public static Command Create()
Start an image generation task using a saved Model Router config instead of naming a model.");
command.Options.Add(XRunwayVersion);
command.Options.Add(ConfigId);
command.Options.Add(DryRun);
command.Options.Add(InputOption);

command.Options.Add(RequestInput);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
command.Validators.Add(result =>
{
var hasInput = result.GetResult(RequestInput) 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 --request-input, --request-json, or --request-file.");
}
});

command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync<global::Runway.CreateGenerateImageRequest>(
parseResult,
RequestInput,
RequestJson,
RequestFile,
global::Runway.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var xRunwayVersion = parseResult.GetRequiredValue(XRunwayVersion);
var configId = parseResult.GetRequiredValue(ConfigId);
var dryRun = CliRuntime.WasSpecified(parseResult, DryRun) ? parseResult.GetValue(DryRun) : (__requestBase is { } __DryRunBaseValue ? __DryRunBaseValue.DryRun : default);
var input = parseResult.GetRequiredValue(InputOption);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.ModelRouter.CreateGenerateImageAsync(
xRunwayVersion: xRunwayVersion,
configId: configId,
dryRun: dryRun,
input: input,
cancellationToken: cancellationToken).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,32 @@ internal static partial class ModelRouterCreateGenerateVideoCommandApiCommand
Required = true,
};

private static Option<bool?> DryRun { get; } = CliRuntime.CreateNullableBoolOption(
name: @"--dry-run",
description: @"When true, run the full routing pipeline and return the decision and estimated cost without generating. No task is created, nothing is billed, and no asset is produced.");

private static Option<global::Runway.CreateGenerateVideoRequestInput> InputOption { get; } = new(
name: @"--input")
{
Description = @"Model-agnostic video generation input. Fields are optional; the router selects a model and maps these options to it.",
Required = true,
};
private static Option<string?> RequestInput { get; } = new(@"--request-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::Runway.CreateGenerateVideoResponse value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
Expand Down Expand Up @@ -54,21 +74,44 @@ public static Command Create()
Start a video generation task using a saved Model Router config instead of naming a model.");
command.Options.Add(XRunwayVersion);
command.Options.Add(ConfigId);
command.Options.Add(DryRun);
command.Options.Add(InputOption);

command.Options.Add(RequestInput);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
command.Validators.Add(result =>
{
var hasInput = result.GetResult(RequestInput) 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 --request-input, --request-json, or --request-file.");
}
});

command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync<global::Runway.CreateGenerateVideoRequest>(
parseResult,
RequestInput,
RequestJson,
RequestFile,
global::Runway.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var xRunwayVersion = parseResult.GetRequiredValue(XRunwayVersion);
var configId = parseResult.GetRequiredValue(ConfigId);
var dryRun = CliRuntime.WasSpecified(parseResult, DryRun) ? parseResult.GetValue(DryRun) : (__requestBase is { } __DryRunBaseValue ? __DryRunBaseValue.DryRun : default);
var input = parseResult.GetRequiredValue(InputOption);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.ModelRouter.CreateGenerateVideoAsync(
xRunwayVersion: xRunwayVersion,
configId: configId,
dryRun: dryRun,
input: input,
cancellationToken: cancellationToken).ConfigureAwait(false);

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

using System.CommandLine;

namespace Runway.Cli.GeneratedApi.Commands;

internal static partial class ModelRouterGetRoutersByIdRequestsCommandApiCommand
{
private static Argument<global::System.Guid> Id { get; } = new(
name: @"id")
{
Description = @"The Model Router's primary key ID (UUID).",
};

private static Option<string?> Cursor { get; } = new(
name: @"--cursor")
{
Description = @"Cursor from a previous response for fetching the next page of results.",
};

private static Option<int> Limit { get; } = new(
name: @"--limit")
{
Description = @"The maximum number of items to return per page.",
Required = true,
};

private static Option<string> XRunwayVersion { get; } = new(
name: @"--x-runway-version")
{
Description = @"The version of the RunwayML API being used. You can read more about versioning [here](/api-details/versioning).",
DefaultValueFactory = _ => "2024-11-06",
};

private static string FormatResponse(ParseResult parseResult, global::Runway.GetRoutersRequestsResponse 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::Runway.GetRoutersRequestsResponse value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


public static Command Create()
{
var command = new Command(@"get-routers-by-id-requests", @"List Model Router requests
Paginated routing history for live Model Router requests (successful routes and failures). Playground dry runs are not recorded.");
command.Arguments.Add(Id);
command.Options.Add(Cursor);
command.Options.Add(Limit);
command.Options.Add(XRunwayVersion);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var id = parseResult.GetRequiredValue(Id);
var cursor = parseResult.GetValue(Cursor);
var limit = parseResult.GetRequiredValue(Limit);
var xRunwayVersion = parseResult.GetRequiredValue(XRunwayVersion);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.ModelRouter.GetRoutersByIdRequestsAsync(
id: id,
cursor: cursor,
limit: limit,
xRunwayVersion: xRunwayVersion,
cancellationToken: cancellationToken).ConfigureAwait(false);


if (!await CliRuntime.TryWriteOutputDirectoryAsync(
parseResult,
response,
global::Runway.SourceGenerationContext.Default,
@"Data",
cancellationToken).ConfigureAwait(false))
{
await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::Runway.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}
}, cancellationToken).ConfigureAwait(false));
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public static Command Create()
var command = new Command(@"organization", @"Organization endpoint commands.");
command.Subcommands.Add(OrganizationCreateOrganizationUsageCommandApiCommand.Create());
command.Subcommands.Add(OrganizationGetOrganizationCommandApiCommand.Create());
command.Subcommands.Add(OrganizationGetOrganizationWebappAuditLogsCommandApiCommand.Create());
command.Subcommands.Add(OrganizationGetOrganizationWebappAuditLogsByEventIdCommandApiCommand.Create());
command.Subcommands.Add(OrganizationGetOrganizationWebappUsageCommandApiCommand.Create());
return command;
}
}
Loading
Loading