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 @@ -33,6 +33,28 @@ internal static partial class ActorRunsPostChargeRunCommandApiCommand
Required = true,
};

private static Option<string?> RequestId { get; } = new(
name: @"--request-id")
{
Description = @"ID of the Server Actor request being charged, from the `X-Actor-Request-ID` header of the incoming request. Required for multi-tenant Server Actor runs, where it identifies the request the charge belongs to.",
};
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::Apify.PostChargeRunResponse value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
Expand Down Expand Up @@ -72,15 +94,37 @@ public static Command Create(string? commandName = null)
command.Options.Add(IdempotencyKey);
command.Options.Add(EventName);
command.Options.Add(Count);

command.Options.Add(RequestId);
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::Apify.ChargeRunRequest>(
parseResult,
Input,
RequestJson,
RequestFile,
global::Apify.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var runId = parseResult.GetRequiredValue(RunId);
var idempotencyKey = parseResult.GetValue(IdempotencyKey);
var eventName = parseResult.GetRequiredValue(EventName);
var count = parseResult.GetRequiredValue(Count);
var requestId = CliRuntime.WasSpecified(parseResult, RequestId) ? parseResult.GetValue(RequestId) : (__requestBase is { } __RequestIdBaseValue ? __RequestIdBaseValue.RequestId : default);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


Expand All @@ -89,6 +133,7 @@ await CliRuntime.RunAsync(async () =>
idempotencyKey: idempotencyKey,
eventName: eventName,
count: count,
requestId: requestId,
cancellationToken: cancellationToken).ConfigureAwait(false);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,9 @@ partial void ProcessPostChargeRunResponseContent(
/// </param>
/// <param name="eventName"></param>
/// <param name="count"></param>
/// <param name="requestId">
/// ID of the Server Actor request being charged, from the `X-Actor-Request-ID` header of the incoming request. Required for multi-tenant Server Actor runs, where it identifies the request the charge belongs to.
/// </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>
Expand All @@ -796,13 +799,15 @@ partial void ProcessPostChargeRunResponseContent(
string eventName,
int count,
string? idempotencyKey = default,
string? requestId = default,
global::Apify.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Apify.ChargeRunRequest
{
EventName = eventName,
Count = count,
RequestId = requestId,
};

return await PostChargeRunAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public partial interface IActorRunsClient
/// </param>
/// <param name="eventName"></param>
/// <param name="count"></param>
/// <param name="requestId">
/// ID of the Server Actor request being charged, from the `X-Actor-Request-ID` header of the incoming request. Required for multi-tenant Server Actor runs, where it identifies the request the charge belongs to.
/// </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>
Expand All @@ -81,6 +84,7 @@ public partial interface IActorRunsClient
string eventName,
int count,
string? idempotencyKey = default,
string? requestId = default,
global::Apify.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
Expand Down
13 changes: 12 additions & 1 deletion src/libs/Apify/Generated/Apify.Models.ChargeRunRequest.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public sealed partial class ChargeRunRequest
[global::System.Text.Json.Serialization.JsonRequired]
public required int Count { get; set; }

/// <summary>
/// ID of the Server Actor request being charged, from the `X-Actor-Request-ID` header of the incoming request. Required for multi-tenant Server Actor runs, where it identifies the request the charge belongs to.
/// </summary>
[global::System.Text.Json.Serialization.JsonPropertyName("requestId")]
public string? RequestId { get; set; }

/// <summary>
/// Additional properties that are not explicitly defined in the schema
/// </summary>
Expand All @@ -33,15 +39,20 @@ public sealed partial class ChargeRunRequest
/// </summary>
/// <param name="eventName"></param>
/// <param name="count"></param>
/// <param name="requestId">
/// ID of the Server Actor request being charged, from the `X-Actor-Request-ID` header of the incoming request. Required for multi-tenant Server Actor runs, where it identifies the request the charge belongs to.
/// </param>
#if NET7_0_OR_GREATER
[global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers]
#endif
public ChargeRunRequest(
string eventName,
int count)
int count,
string? requestId)
{
this.EventName = eventName ?? throw new global::System.ArgumentNullException(nameof(eventName));
this.Count = count;
this.RequestId = requestId;
}

/// <summary>
Expand Down
Loading
Loading