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 @@ -18,6 +18,7 @@ public static Command Create()
command.Subcommands.Add(StartGeneratingCreateTextToSpeechCommandApiCommand.Create());
command.Subcommands.Add(StartGeneratingCreateTextToVideoCommandApiCommand.Create());
command.Subcommands.Add(StartGeneratingCreateVideoToVideoCommandApiCommand.Create());
command.Subcommands.Add(StartGeneratingCreateVideoUpscaleCommandApiCommand.Create());
command.Subcommands.Add(StartGeneratingCreateVoiceDubbingCommandApiCommand.Create());
command.Subcommands.Add(StartGeneratingCreateVoiceIsolationCommandApiCommand.Create());
return command;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace Runway.Cli.GeneratedApi.Commands;

internal static partial class StartGeneratingCreateVideoUpscaleCommandApiCommand
{
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 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::Runway.CreateVideoUpscaleResponse 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.CreateVideoUpscaleResponse value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


public static Command Create()
{
var command = new Command(@"create-video-upscale", @"Video upscale
This endpoint starts a task to upscale a video. Set `model` to choose the upscaler.");
command.Options.Add(XRunwayVersion);
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 xRunwayVersion = parseResult.GetRequiredValue(XRunwayVersion);
var request = await CliRuntime.ReadRequestAsync<global::Runway.CreateVideoUpscaleRequest>(
parseResult,
Input,
RequestJson,
RequestFile,
global::Runway.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.StartGenerating.CreateVideoUpscaleAsync(
xRunwayVersion: xRunwayVersion,
request: request,
cancellationToken: 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
@@ -0,0 +1,84 @@
#nullable enable

namespace Runway
{
public partial interface IStartGeneratingClient
{
/// <summary>
/// Video upscale<br/>
/// This endpoint starts a task to upscale a video. Set `model` to choose the upscaler.
/// </summary>
/// <param name="xRunwayVersion">
/// Default Value: 2024-11-06
/// </param>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Runway.ApiException"></exception>
/// <remarks>
/// // npm install --save @runwayml/sdk<br/>
/// import RunwayML from '@runwayml/sdk';<br/>
/// // The env var RUNWAYML_API_SECRET is expected to contain your API key.<br/>
/// const client = new RunwayML();<br/>
/// const task = await client.videoUpscale<br/>
/// .create({<br/>
/// model: 'magnific_video_upscaler_creative',<br/>
/// videoUri: 'https://example.com/bunny.mp4',<br/>
/// resolution: '2k',<br/>
/// })<br/>
/// .waitForTaskOutput();<br/>
/// console.log(task);
/// </remarks>
global::System.Threading.Tasks.Task<global::Runway.CreateVideoUpscaleResponse> CreateVideoUpscaleAsync(

global::Runway.CreateVideoUpscaleRequest request,
string xRunwayVersion = "2024-11-06",
global::Runway.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Video upscale<br/>
/// This endpoint starts a task to upscale a video. Set `model` to choose the upscaler.
/// </summary>
/// <param name="xRunwayVersion">
/// Default Value: 2024-11-06
/// </param>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Runway.ApiException"></exception>
/// <remarks>
/// // npm install --save @runwayml/sdk<br/>
/// import RunwayML from '@runwayml/sdk';<br/>
/// // The env var RUNWAYML_API_SECRET is expected to contain your API key.<br/>
/// const client = new RunwayML();<br/>
/// const task = await client.videoUpscale<br/>
/// .create({<br/>
/// model: 'magnific_video_upscaler_creative',<br/>
/// videoUri: 'https://example.com/bunny.mp4',<br/>
/// resolution: '2k',<br/>
/// })<br/>
/// .waitForTaskOutput();<br/>
/// console.log(task);
/// </remarks>
global::System.Threading.Tasks.Task<global::Runway.AutoSDKHttpResponse<global::Runway.CreateVideoUpscaleResponse>> CreateVideoUpscaleAsResponseAsync(

global::Runway.CreateVideoUpscaleRequest request,
string xRunwayVersion = "2024-11-06",
global::Runway.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Video upscale<br/>
/// This endpoint starts a task to upscale a video. Set `model` to choose the upscaler.
/// </summary>
/// <param name="xRunwayVersion">
/// Default Value: 2024-11-06
/// </param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::Runway.CreateVideoUpscaleResponse> CreateVideoUpscaleAsync(
string xRunwayVersion = "2024-11-06",
global::Runway.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#nullable enable
#pragma warning disable CS0618 // Type or member is obsolete

namespace Runway.JsonConverters
{
/// <inheritdoc />
public class CreateVideoUpscaleRequestJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Runway.CreateVideoUpscaleRequest>
{
/// <inheritdoc />
public override global::Runway.CreateVideoUpscaleRequest 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.");


var readerCopy = reader;
var discriminatorTypeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Runway.CreateVideoUpscaleRequestDiscriminator), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Runway.CreateVideoUpscaleRequestDiscriminator> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Runway.CreateVideoUpscaleRequestDiscriminator)}");
var discriminator = global::System.Text.Json.JsonSerializer.Deserialize(ref readerCopy, discriminatorTypeInfo);

global::Runway.CreateVideoUpscaleRequestMagnificVideoUpscalerCreative? magnificVideoUpscalerCreative = default;
if (discriminator?.Model == global::Runway.CreateVideoUpscaleRequestDiscriminatorModel.MagnificVideoUpscalerCreative)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Runway.CreateVideoUpscaleRequestMagnificVideoUpscalerCreative), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Runway.CreateVideoUpscaleRequestMagnificVideoUpscalerCreative> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {nameof(global::Runway.CreateVideoUpscaleRequestMagnificVideoUpscalerCreative)}");
magnificVideoUpscalerCreative = global::System.Text.Json.JsonSerializer.Deserialize(ref reader, typeInfo);
}

var __value = new global::Runway.CreateVideoUpscaleRequest(
discriminator?.Model,
magnificVideoUpscalerCreative
);

return __value;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Runway.CreateVideoUpscaleRequest 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.");

if (value.IsMagnificVideoUpscalerCreative)
{
var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Runway.CreateVideoUpscaleRequestMagnificVideoUpscalerCreative), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Runway.CreateVideoUpscaleRequestMagnificVideoUpscalerCreative?> ??
throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Runway.CreateVideoUpscaleRequestMagnificVideoUpscalerCreative).Name}");
global::System.Text.Json.JsonSerializer.Serialize(writer, value.MagnificVideoUpscalerCreative!, typeInfo);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#nullable enable

namespace Runway.JsonConverters
{
/// <inheritdoc />
public sealed class CreateVideoUpscaleRequestDiscriminatorModelJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Runway.CreateVideoUpscaleRequestDiscriminatorModel>
{
/// <inheritdoc />
public override global::Runway.CreateVideoUpscaleRequestDiscriminatorModel 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::Runway.CreateVideoUpscaleRequestDiscriminatorModelExtensions.ToEnum(stringValue) ?? default;
}

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

return default;
}

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

writer.WriteStringValue(global::Runway.CreateVideoUpscaleRequestDiscriminatorModelExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#nullable enable

namespace Runway.JsonConverters
{
/// <inheritdoc />
public sealed class CreateVideoUpscaleRequestDiscriminatorModelNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Runway.CreateVideoUpscaleRequestDiscriminatorModel?>
{
/// <inheritdoc />
public override global::Runway.CreateVideoUpscaleRequestDiscriminatorModel? 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::Runway.CreateVideoUpscaleRequestDiscriminatorModelExtensions.ToEnum(stringValue);
}

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

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Runway.CreateVideoUpscaleRequestDiscriminatorModel? 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::Runway.CreateVideoUpscaleRequestDiscriminatorModelExtensions.ToValueString(value.Value));
}
}
}
}
Loading
Loading