diff --git a/src/cli/Apify.CLI/CliRuntime.cs b/src/cli/Apify.CLI/CliRuntime.cs index 1e4801c..f14f2ba 100644 --- a/src/cli/Apify.CLI/CliRuntime.cs +++ b/src/cli/Apify.CLI/CliRuntime.cs @@ -4,9 +4,6 @@ using System.CommandLine.Parsing; using System.Globalization; using System.Text; -using System.Text.Json; -using System.Text.Json.Nodes; -using System.Text.Json.Serialization; namespace Apify.CLI; @@ -131,7 +128,7 @@ internal static class CliRuntime var values = await ReadUserSecretsAsync(cancellationToken).ConfigureAwait(false); values[name] = value; - var json = PrettyJson(JsonSerializer.Serialize(values, UserSecretsJsonContext.Default.DictionaryStringString)); + var json = PrettyJson(global::System.Text.Json.JsonSerializer.Serialize(values, UserSecretsJsonContext.Default.DictionaryStringString)); await File.WriteAllTextAsync(path, json, cancellationToken).ConfigureAwait(false); } @@ -149,7 +146,7 @@ internal static class CliRuntime return; } - var json = PrettyJson(JsonSerializer.Serialize(values, UserSecretsJsonContext.Default.DictionaryStringString)); + var json = PrettyJson(global::System.Text.Json.JsonSerializer.Serialize(values, UserSecretsJsonContext.Default.DictionaryStringString)); await File.WriteAllTextAsync(path, json, cancellationToken).ConfigureAwait(false); } @@ -311,7 +308,7 @@ public static TimeSpan ParseDuration(string value, string optionName) Option inputOption, Option requestJsonOption, Option requestFileOption, - JsonSerializerContext context, + global::System.Text.Json.Serialization.JsonSerializerContext context, CancellationToken cancellationToken = default) { var requestJson = await ReadInputAsync( @@ -322,7 +319,7 @@ public static TimeSpan ParseDuration(string value, string optionName) required: true, cancellationToken).ConfigureAwait(false); - var value = JsonSerializer.Deserialize(requestJson ?? throw new CliException("Request input is required."), typeof(T), context); + var value = global::System.Text.Json.JsonSerializer.Deserialize(requestJson ?? throw new CliException("Request input is required."), typeof(T), context); return value is T typed ? typed : throw new CliException($"Unable to deserialize request JSON as {typeof(T).Name}."); @@ -333,7 +330,7 @@ public static TimeSpan ParseDuration(string value, string optionName) Option inputOption, Option requestJsonOption, Option requestFileOption, - JsonSerializerContext context, + global::System.Text.Json.Serialization.JsonSerializerContext context, CancellationToken cancellationToken = default) { var requestJson = await ReadInputAsync( @@ -347,15 +344,15 @@ public static TimeSpan ParseDuration(string value, string optionName) return default; } - var value = JsonSerializer.Deserialize(requestJson!, typeof(T), context); + var value = global::System.Text.Json.JsonSerializer.Deserialize(requestJson!, typeof(T), context); return value is T typed ? typed : throw new CliException($"Unable to deserialize request JSON as {typeof(T).Name}."); } - public static T DeserializeJsonValue(string json, JsonSerializerContext context) + public static T DeserializeJsonValue(string json, global::System.Text.Json.Serialization.JsonSerializerContext context) { - var value = JsonSerializer.Deserialize(json, typeof(T), context); + var value = global::System.Text.Json.JsonSerializer.Deserialize(json, typeof(T), context); return value is T typed ? typed : throw new CliException($"Unable to deserialize generated CLI value as {typeof(T).Name}."); @@ -363,7 +360,7 @@ public static T DeserializeJsonValue(string json, JsonSerializerContext conte public static string SerializeKeyValuePairs(IEnumerable pairs) { - var objectNode = new JsonObject(); + var objectNode = new global::System.Text.Json.Nodes.JsonObject(); foreach (var pair in pairs) { var separatorIndex = pair.IndexOf('=', StringComparison.Ordinal); @@ -387,32 +384,32 @@ public static string SerializeKeyValuePairs(IEnumerable pairs) public static string SerializeStringArray(IEnumerable values) { - var array = new JsonArray(); + var array = new global::System.Text.Json.Nodes.JsonArray(); foreach (var value in values) { - array.Add((JsonNode?)JsonValue.Create(value)); + array.Add((global::System.Text.Json.Nodes.JsonNode?)global::System.Text.Json.Nodes.JsonValue.Create(value)); } return array.ToJsonString(); } - public static async global::System.Threading.Tasks.Task WriteJsonAsync(ParseResult parseResult, T value, JsonSerializerContext context, CancellationToken cancellationToken = default) + public static async global::System.Threading.Tasks.Task WriteJsonAsync(ParseResult parseResult, T value, global::System.Text.Json.Serialization.JsonSerializerContext context, CancellationToken cancellationToken = default) { - var json = JsonSerializer.Serialize(value, typeof(T), context); + var json = global::System.Text.Json.JsonSerializer.Serialize(value, typeof(T), context); await WriteTextAsync(parseResult, PrettyJson(json), cancellationToken: cancellationToken).ConfigureAwait(false); } - public static async global::System.Threading.Tasks.Task WriteJsonLineAsync(ParseResult parseResult, T value, JsonSerializerContext context, CancellationToken cancellationToken = default) + public static async global::System.Threading.Tasks.Task WriteJsonLineAsync(ParseResult parseResult, T value, global::System.Text.Json.Serialization.JsonSerializerContext context, CancellationToken cancellationToken = default) { - var json = JsonSerializer.Serialize(value, typeof(T), context); + var json = global::System.Text.Json.JsonSerializer.Serialize(value, typeof(T), context); await WriteTextAsync(parseResult, json + Environment.NewLine, append: true, cancellationToken: cancellationToken).ConfigureAwait(false); } public static async global::System.Threading.Tasks.Task WriteResponseAsync( ParseResult parseResult, T value, - JsonSerializerContext context, - Func? formatter = null, + global::System.Text.Json.Serialization.JsonSerializerContext context, + Func? formatter = null, CancellationToken cancellationToken = default) { if (parseResult.GetValue(CliOptions.Json)) @@ -431,8 +428,8 @@ public static string SerializeStringArray(IEnumerable values) public static async global::System.Threading.Tasks.Task WriteResponseLineAsync( ParseResult parseResult, T value, - JsonSerializerContext context, - Func? formatter = null, + global::System.Text.Json.Serialization.JsonSerializerContext context, + Func? formatter = null, CancellationToken cancellationToken = default) { if (parseResult.GetValue(CliOptions.Json)) @@ -451,7 +448,7 @@ public static string SerializeStringArray(IEnumerable values) public static async global::System.Threading.Tasks.Task TryWriteOutputDirectoryAsync( ParseResult parseResult, T value, - JsonSerializerContext context, + global::System.Text.Json.Serialization.JsonSerializerContext context, string itemsPropertyName, CancellationToken cancellationToken = default) { @@ -463,8 +460,8 @@ public static string SerializeStringArray(IEnumerable values) var rootNode = ToJsonNode(value, typeof(T), context); var items = itemsPropertyName == "$self" - ? rootNode as JsonArray - : rootNode?[itemsPropertyName] as JsonArray; + ? rootNode as global::System.Text.Json.Nodes.JsonArray + : rootNode?[itemsPropertyName] as global::System.Text.Json.Nodes.JsonArray; if (items is null) { throw new CliException("The response does not contain a writable item collection for --output-dir."); @@ -565,7 +562,7 @@ public static string MaskSecret(string secret) return new Dictionary(StringComparer.Ordinal); } - return JsonSerializer.Deserialize(json, UserSecretsJsonContext.Default.DictionaryStringString) ?? + return global::System.Text.Json.JsonSerializer.Deserialize(json, UserSecretsJsonContext.Default.DictionaryStringString) ?? new Dictionary(StringComparer.Ordinal); } @@ -656,22 +653,22 @@ private static bool EndsWithUnit(string value, char unit) return await File.ReadAllTextAsync(pathOrDash, cancellationToken).ConfigureAwait(false); } - private static JsonNode? ToJsonNode(T value, Type type, JsonSerializerContext context) + private static global::System.Text.Json.Nodes.JsonNode? ToJsonNode(T value, Type type, global::System.Text.Json.Serialization.JsonSerializerContext context) { - var json = JsonSerializer.Serialize(value, type, context); - return JsonNode.Parse(json); + var json = global::System.Text.Json.JsonSerializer.Serialize(value, type, context); + return global::System.Text.Json.Nodes.JsonNode.Parse(json); } - private static JsonElement ToJsonElement(T value, JsonSerializerContext context) + private static global::System.Text.Json.JsonElement ToJsonElement(T value, global::System.Text.Json.Serialization.JsonSerializerContext context) { - var json = JsonSerializer.Serialize(value, typeof(T), context); - using var document = JsonDocument.Parse(json); + var json = global::System.Text.Json.JsonSerializer.Serialize(value, typeof(T), context); + using var document = global::System.Text.Json.JsonDocument.Parse(json); return document.RootElement.Clone(); } public static string FormatHumanReadable( T value, - JsonSerializerContext context, + global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings, IReadOnlyDictionary? formatHints = null) { @@ -684,7 +681,7 @@ public static string FormatHumanReadable( private static void AppendFormattedValue( StringBuilder builder, string? name, - JsonElement element, + global::System.Text.Json.JsonElement element, int indent, bool truncateLongStrings, IReadOnlyDictionary? formatHints, @@ -695,7 +692,7 @@ private static void AppendFormattedValue( return; } - if (element.ValueKind == JsonValueKind.String && + if (element.ValueKind == global::System.Text.Json.JsonValueKind.String && HasFormatHint(path, CliFormatHint.Code, formatHints)) { AppendCodeBlock(builder, name, element.GetString() ?? string.Empty, indent); @@ -704,10 +701,10 @@ private static void AppendFormattedValue( switch (element.ValueKind) { - case JsonValueKind.Object: + case global::System.Text.Json.JsonValueKind.Object: AppendFormattedObject(builder, name, element, indent, truncateLongStrings, formatHints, path); break; - case JsonValueKind.Array: + case global::System.Text.Json.JsonValueKind.Array: AppendFormattedArray(builder, name, element, indent, truncateLongStrings, formatHints, path); break; default: @@ -719,7 +716,7 @@ private static void AppendFormattedValue( private static void AppendFormattedObject( StringBuilder builder, string? name, - JsonElement element, + global::System.Text.Json.JsonElement element, int indent, bool truncateLongStrings, IReadOnlyDictionary? formatHints, @@ -751,7 +748,7 @@ private static void AppendFormattedObject( private static void AppendFormattedArray( StringBuilder builder, string? name, - JsonElement element, + global::System.Text.Json.JsonElement element, int indent, bool truncateLongStrings, IReadOnlyDictionary? formatHints, @@ -770,7 +767,7 @@ private static void AppendFormattedArray( return; } - if (items.All(static item => item.ValueKind is not JsonValueKind.Object and not JsonValueKind.Array)) + if (items.All(static item => item.ValueKind is not global::System.Text.Json.JsonValueKind.Object and not global::System.Text.Json.JsonValueKind.Array)) { foreach (var item in items) { @@ -787,15 +784,15 @@ private static void AppendFormattedArray( } } - private static string FormatScalar(JsonElement element, bool truncateLongStrings) + private static string FormatScalar(global::System.Text.Json.JsonElement element, bool truncateLongStrings) { return element.ValueKind switch { - JsonValueKind.String => FormatStringScalar(element.GetString() ?? string.Empty, truncateLongStrings), - JsonValueKind.True => "true", - JsonValueKind.False => "false", - JsonValueKind.Number => element.GetRawText(), - JsonValueKind.Null => "null", + global::System.Text.Json.JsonValueKind.String => FormatStringScalar(element.GetString() ?? string.Empty, truncateLongStrings), + global::System.Text.Json.JsonValueKind.True => "true", + global::System.Text.Json.JsonValueKind.False => "false", + global::System.Text.Json.JsonValueKind.Number => element.GetRawText(), + global::System.Text.Json.JsonValueKind.Null => "null", _ => element.GetRawText(), }; } @@ -859,18 +856,18 @@ private static void AppendLine(StringBuilder builder, int indent, string value) builder.AppendLine(value); } - private static async global::System.Threading.Tasks.Task WriteItemFilesAsync(string outputDirectory, JsonArray items, CancellationToken cancellationToken = default) + private static async global::System.Threading.Tasks.Task WriteItemFilesAsync(string outputDirectory, global::System.Text.Json.Nodes.JsonArray items, CancellationToken cancellationToken = default) { Directory.CreateDirectory(outputDirectory); for (var index = 0; index < items.Count; index++) { - if (items[index] is not JsonNode itemNode) + if (items[index] is not global::System.Text.Json.Nodes.JsonNode itemNode) { continue; } - var itemObject = itemNode as JsonObject; + var itemObject = itemNode as global::System.Text.Json.Nodes.JsonObject; var baseName = itemObject is null ? $"{index + 1:000}" : SanitizeFileName(GetOutputItemName(itemObject) ?? $"{index + 1:000}"); @@ -884,7 +881,7 @@ private static void AppendLine(StringBuilder builder, int indent, string value) wroteStructuredFile |= await TryWriteTextPropertyAsync(itemObject, outputDirectory, baseName, "raw_html", ".raw.html", cancellationToken).ConfigureAwait(false); wroteStructuredFile |= await TryWriteTextPropertyAsync(itemObject, outputDirectory, baseName, "text", ".txt", cancellationToken).ConfigureAwait(false); - if (TryGetNamedNode(itemObject, out var linksNode, "links") && linksNode is JsonArray links) + if (TryGetNamedNode(itemObject, out var linksNode, "links") && linksNode is global::System.Text.Json.Nodes.JsonArray links) { var linkLines = links .Select(static node => node?.GetValue()) @@ -901,7 +898,7 @@ await File.WriteAllTextAsync( } } - var json = itemNode.ToJsonString(new JsonSerializerOptions { WriteIndented = true }); + var json = itemNode.ToJsonString(new global::System.Text.Json.JsonSerializerOptions { WriteIndented = true }); var fileName = wroteStructuredFile ? $"{baseName}.metadata.json" : $"{baseName}.json"; @@ -910,7 +907,7 @@ await File.WriteAllTextAsync( } private static async global::System.Threading.Tasks.Task TryWriteTextPropertyAsync( - JsonObject item, + global::System.Text.Json.Nodes.JsonObject item, string outputDirectory, string baseName, string propertyName, @@ -935,7 +932,7 @@ await File.WriteAllTextAsync( return true; } - private static string? GetOutputItemName(JsonObject item) + private static string? GetOutputItemName(global::System.Text.Json.Nodes.JsonObject item) { if (TryGetNamedNode(item, out var node, "url", "sourceUrl", "source_url", "id")) { @@ -945,7 +942,7 @@ await File.WriteAllTextAsync( return null; } - private static bool TryGetNamedNode(JsonObject item, out JsonNode? node, params string[] names) + private static bool TryGetNamedNode(global::System.Text.Json.Nodes.JsonObject item, out global::System.Text.Json.Nodes.JsonNode? node, params string[] names) { foreach (var property in item) { @@ -993,9 +990,9 @@ private static string SanitizeFileName(string value) private static string PrettyJson(string json) { - using var document = JsonDocument.Parse(json); + using var document = global::System.Text.Json.JsonDocument.Parse(json); using var stream = new MemoryStream(); - using (var writer = new Utf8JsonWriter(stream, new JsonWriterOptions { Indented = true })) + using (var writer = new global::System.Text.Json.Utf8JsonWriter(stream, new global::System.Text.Json.JsonWriterOptions { Indented = true })) { document.WriteTo(writer); } @@ -1072,6 +1069,6 @@ internal sealed record AuthSourceProbe(string Source, string DisplayName, string public bool Present => !string.IsNullOrWhiteSpace(RawValue); } -[JsonSerializable(typeof(AuthStatusInfo))] -[JsonSerializable(typeof(Dictionary))] -internal sealed partial class UserSecretsJsonContext : JsonSerializerContext; \ No newline at end of file +[global::System.Text.Json.Serialization.JsonSerializable(typeof(AuthStatusInfo))] +[global::System.Text.Json.Serialization.JsonSerializable(typeof(Dictionary))] +internal sealed partial class UserSecretsJsonContext : global::System.Text.Json.Serialization.JsonSerializerContext; \ No newline at end of file diff --git a/src/libs/Apify/Generated/Apify.DefaultDatasetClient.ActorRunDatasetItemsGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.DefaultDatasetClient.ActorRunDatasetItemsGetAsBytes.g.cs index 60a0a37..bb5433d 100644 --- a/src/libs/Apify/Generated/Apify.DefaultDatasetClient.ActorRunDatasetItemsGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.DefaultDatasetClient.ActorRunDatasetItemsGetAsBytes.g.cs @@ -944,6 +944,769 @@ partial void ProcessActorRunDatasetItemsGetAsBytesResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Get the default dataset items from an Actor run
+ /// Returns data stored in the default dataset of the Actor run in the desired format.
+ /// This endpoint is a shortcut that resolves the run's `defaultDatasetId` and proxies to the
+ /// [Get dataset items](/api/v2/dataset-items-get) endpoint. + ///
+ /// + /// Example: 3KH8gEpp4d8uQSe8T + /// + /// + /// Example: json + /// + /// + /// Example: false + /// + /// + /// Example: 0 + /// + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: title,link + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue + /// + /// + /// Example: true + /// + /// + /// Example: true + /// + /// + /// Example: ; + /// + /// + /// Example: false + /// + /// + /// Example: items + /// + /// + /// Example: item + /// + /// + /// Example: true + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: overview + /// + /// + /// Example: false + /// + /// + /// Example: Latest posts from r/pasta + /// + /// + /// Example: Scraped forum posts + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorRunDatasetItemsGetAsBytesAsStreamAsResponseAsync( + string runId, + string? format = default, + bool? clean = default, + double? offset = default, + double? limit = default, + string? fields = default, + string? outputFields = default, + string? omit = default, + string? unwind = default, + string? flatten = default, + bool? desc = default, + bool? attachment = default, + string? delimiter = default, + bool? bom = default, + string? xmlRoot = default, + string? xmlRow = default, + bool? skipHeaderRow = default, + bool? skipHidden = default, + bool? skipEmpty = default, + bool? simplified = default, + string? view = default, + bool? skipFailedPages = default, + string? feedTitle = default, + string? feedDescription = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorRunDatasetItemsGetAsBytesArguments( + httpClient: HttpClient, + runId: ref runId, + format: ref format, + clean: ref clean, + offset: ref offset, + limit: ref limit, + fields: ref fields, + outputFields: ref outputFields, + omit: ref omit, + unwind: ref unwind, + flatten: ref flatten, + desc: ref desc, + attachment: ref attachment, + delimiter: ref delimiter, + bom: ref bom, + xmlRoot: ref xmlRoot, + xmlRow: ref xmlRow, + skipHeaderRow: ref skipHeaderRow, + skipHidden: ref skipHidden, + skipEmpty: ref skipEmpty, + simplified: ref simplified, + view: ref view, + skipFailedPages: ref skipFailedPages, + feedTitle: ref feedTitle, + feedDescription: ref feedDescription, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorRunDatasetItemsGetAsBytesSecurityRequirements, + operationName: "ActorRunDatasetItemsGetAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actor-runs/{runId}/dataset/items", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("format", format) + .AddOptionalParameter("clean", clean?.ToString().ToLowerInvariant()) + .AddOptionalParameter("offset", offset?.ToString()) + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("fields", fields) + .AddOptionalParameter("outputFields", outputFields) + .AddOptionalParameter("omit", omit) + .AddOptionalParameter("unwind", unwind) + .AddOptionalParameter("flatten", flatten) + .AddOptionalParameter("desc", desc?.ToString().ToLowerInvariant()) + .AddOptionalParameter("attachment", attachment?.ToString().ToLowerInvariant()) + .AddOptionalParameter("delimiter", delimiter) + .AddOptionalParameter("bom", bom?.ToString().ToLowerInvariant()) + .AddOptionalParameter("xmlRoot", xmlRoot) + .AddOptionalParameter("xmlRow", xmlRow) + .AddOptionalParameter("skipHeaderRow", skipHeaderRow?.ToString().ToLowerInvariant()) + .AddOptionalParameter("skipHidden", skipHidden?.ToString().ToLowerInvariant()) + .AddOptionalParameter("skipEmpty", skipEmpty?.ToString().ToLowerInvariant()) + .AddOptionalParameter("simplified", simplified?.ToString().ToLowerInvariant()) + .AddOptionalParameter("view", view) + .AddOptionalParameter("skipFailedPages", skipFailedPages?.ToString().ToLowerInvariant()) + .AddOptionalParameter("feedTitle", feedTitle) + .AddOptionalParameter("feedDescription", feedDescription) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorRunDatasetItemsGetAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + runId: runId, + format: format, + clean: clean, + offset: offset, + limit: limit, + fields: fields, + outputFields: outputFields, + omit: omit, + unwind: unwind, + flatten: flatten, + desc: desc, + attachment: attachment, + delimiter: delimiter, + bom: bom, + xmlRoot: xmlRoot, + xmlRow: xmlRow, + skipHeaderRow: skipHeaderRow, + skipHidden: skipHidden, + skipEmpty: skipEmpty, + simplified: simplified, + view: view, + skipFailedPages: skipFailedPages, + feedTitle: feedTitle, + feedDescription: feedDescription, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunDatasetItemsGetAsBytes", + methodName: "ActorRunDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunDatasetItemsGetAsBytes", + methodName: "ActorRunDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunDatasetItemsGetAsBytes", + methodName: "ActorRunDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorRunDatasetItemsGetAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunDatasetItemsGetAsBytes", + methodName: "ActorRunDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunDatasetItemsGetAsBytes", + methodName: "ActorRunDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Payment required - the user has exceeded their usage limit, does not have enough credits, or the request lacks authentication and payment credentials. + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Apify.ErrorResponse? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.DefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.DefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordGetAsBytes.g.cs index 0e7ec23..53eb533 100644 --- a/src/libs/Apify/Generated/Apify.DefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.DefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordGetAsBytes.g.cs @@ -685,6 +685,655 @@ partial void ProcessActorRunKeyValueStoreRecordGetAsBytesResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Get record from the default key-value store of an Actor run
+ /// Gets a value stored under a specific key in the default key-value store of the Actor run.
+ /// This endpoint is a shortcut for getting the run's `defaultKeyValueStoreId` and then using the
+ /// [Get key-value store record](/api/v2/key-value-store-record-get) endpoint. + ///
+ /// + /// Example: 3KH8gEpp4d8uQSe8T + /// + /// + /// Example: someKey + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// + /// Example: true + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorRunKeyValueStoreRecordGetAsBytesAsStreamAsResponseAsync( + string runId, + string recordKey, + string? signature = default, + bool? attachment = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorRunKeyValueStoreRecordGetAsBytesArguments( + httpClient: HttpClient, + runId: ref runId, + recordKey: ref recordKey, + signature: ref signature, + attachment: ref attachment); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorRunKeyValueStoreRecordGetAsBytesSecurityRequirements, + operationName: "ActorRunKeyValueStoreRecordGetAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actor-runs/{runId}/key-value-store/records/{recordKey}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("signature", signature) + .AddOptionalParameter("attachment", attachment?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "*/*"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorRunKeyValueStoreRecordGetAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + runId: runId, + recordKey: recordKey, + signature: signature, + attachment: attachment); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorRunKeyValueStoreRecordGetAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 302) + { + string? __content_302 = null; + global::System.Exception? __exception_302 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_302 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_302 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_302, + responseBody: __content_302, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Payment required - the user has exceeded their usage limit, does not have enough credits, or the request lacks authentication and payment credentials. + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Apify.ErrorResponse? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.DefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordsGet.g.cs b/src/libs/Apify/Generated/Apify.DefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordsGet.g.cs index 71b1bda..6432467 100644 --- a/src/libs/Apify/Generated/Apify.DefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordsGet.g.cs +++ b/src/libs/Apify/Generated/Apify.DefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordsGet.g.cs @@ -613,6 +613,583 @@ partial void ProcessActorRunKeyValueStoreRecordsGetResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Download records from the default key-value store of an Actor run
+ /// Downloads all records from the default key-value store of the Actor run as a ZIP archive.
+ /// This endpoint is a shortcut for getting the run's `defaultKeyValueStoreId` and then using the
+ /// [Download key-value store records](/api/v2/key-value-store-records-get) endpoint. + ///
+ /// + /// Example: 3KH8gEpp4d8uQSe8T + /// + /// + /// Example: my-collection + /// + /// + /// Example: my-prefix/ + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorRunKeyValueStoreRecordsGetAsStreamAsResponseAsync( + string runId, + string? collection = default, + string? prefix = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorRunKeyValueStoreRecordsGetArguments( + httpClient: HttpClient, + runId: ref runId, + collection: ref collection, + prefix: ref prefix, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorRunKeyValueStoreRecordsGetSecurityRequirements, + operationName: "ActorRunKeyValueStoreRecordsGetAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actor-runs/{runId}/key-value-store/records", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("collection", collection) + .AddOptionalParameter("prefix", prefix) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorRunKeyValueStoreRecordsGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + runId: runId, + collection: collection, + prefix: prefix, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordsGet", + methodName: "ActorRunKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordsGet", + methodName: "ActorRunKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordsGet", + methodName: "ActorRunKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorRunKeyValueStoreRecordsGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordsGet", + methodName: "ActorRunKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunKeyValueStoreRecordsGet", + methodName: "ActorRunKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-runs/{runId}/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.IDefaultDatasetClient.ActorRunDatasetItemsGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.IDefaultDatasetClient.ActorRunDatasetItemsGetAsBytes.g.cs index 751ff8b..90df8ea 100644 --- a/src/libs/Apify/Generated/Apify.IDefaultDatasetClient.ActorRunDatasetItemsGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.IDefaultDatasetClient.ActorRunDatasetItemsGetAsBytes.g.cs @@ -303,6 +303,117 @@ public partial interface IDefaultDatasetClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorRunDatasetItemsGetAsBytesAsStreamAsResponseAsync( + string runId, + string? format = default, + bool? clean = default, + double? offset = default, + double? limit = default, + string? fields = default, + string? outputFields = default, + string? omit = default, + string? unwind = default, + string? flatten = default, + bool? desc = default, + bool? attachment = default, + string? delimiter = default, + bool? bom = default, + string? xmlRoot = default, + string? xmlRow = default, + bool? skipHeaderRow = default, + bool? skipHidden = default, + bool? skipEmpty = default, + bool? simplified = default, + string? view = default, + bool? skipFailedPages = default, + string? feedTitle = default, + string? feedDescription = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get the default dataset items from an Actor run
+ /// Returns data stored in the default dataset of the Actor run in the desired format.
+ /// This endpoint is a shortcut that resolves the run's `defaultDatasetId` and proxies to the
+ /// [Get dataset items](/api/v2/dataset-items-get) endpoint. + ///
+ /// + /// Example: 3KH8gEpp4d8uQSe8T + /// + /// + /// Example: json + /// + /// + /// Example: false + /// + /// + /// Example: 0 + /// + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: title,link + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue + /// + /// + /// Example: true + /// + /// + /// Example: true + /// + /// + /// Example: ; + /// + /// + /// Example: false + /// + /// + /// Example: items + /// + /// + /// Example: item + /// + /// + /// Example: true + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: overview + /// + /// + /// Example: false + /// + /// + /// Example: Latest posts from r/pasta + /// + /// + /// Example: Scraped forum posts + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.IDefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.IDefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordGetAsBytes.g.cs index 7771de6..52d8704 100644 --- a/src/libs/Apify/Generated/Apify.IDefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.IDefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordGetAsBytes.g.cs @@ -78,6 +78,35 @@ public partial interface IDefaultKeyValueStoreClient /// /// Example: true /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorRunKeyValueStoreRecordGetAsBytesAsStreamAsResponseAsync( + string runId, + string recordKey, + string? signature = default, + bool? attachment = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get record from the default key-value store of an Actor run
+ /// Gets a value stored under a specific key in the default key-value store of the Actor run.
+ /// This endpoint is a shortcut for getting the run's `defaultKeyValueStoreId` and then using the
+ /// [Get key-value store record](/api/v2/key-value-store-record-get) endpoint. + ///
+ /// + /// Example: 3KH8gEpp4d8uQSe8T + /// + /// + /// Example: someKey + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// + /// Example: true + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.IDefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordsGet.g.cs b/src/libs/Apify/Generated/Apify.IDefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordsGet.g.cs index d87916f..a19bbad 100644 --- a/src/libs/Apify/Generated/Apify.IDefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordsGet.g.cs +++ b/src/libs/Apify/Generated/Apify.IDefaultKeyValueStoreClient.ActorRunKeyValueStoreRecordsGet.g.cs @@ -78,6 +78,35 @@ public partial interface IDefaultKeyValueStoreClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorRunKeyValueStoreRecordsGetAsStreamAsResponseAsync( + string runId, + string? collection = default, + string? prefix = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download records from the default key-value store of an Actor run
+ /// Downloads all records from the default key-value store of the Actor run as a ZIP archive.
+ /// This endpoint is a shortcut for getting the run's `defaultKeyValueStoreId` and then using the
+ /// [Download key-value store records](/api/v2/key-value-store-records-get) endpoint. + ///
+ /// + /// Example: 3KH8gEpp4d8uQSe8T + /// + /// + /// Example: my-collection + /// + /// + /// Example: my-prefix/ + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultDatasetClient.ActorRunsLastDatasetItemsGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultDatasetClient.ActorRunsLastDatasetItemsGetAsBytes.g.cs index 9a38134..25095ba 100644 --- a/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultDatasetClient.ActorRunsLastDatasetItemsGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultDatasetClient.ActorRunsLastDatasetItemsGetAsBytes.g.cs @@ -319,6 +319,123 @@ public partial interface ILastActorRunSDefaultDatasetClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorRunsLastDatasetItemsGetAsBytesAsStreamAsResponseAsync( + string actorId, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? format = default, + bool? clean = default, + double? offset = default, + double? limit = default, + string? fields = default, + string? outputFields = default, + string? omit = default, + string? unwind = default, + string? flatten = default, + bool? desc = default, + bool? attachment = default, + string? delimiter = default, + bool? bom = default, + string? xmlRoot = default, + string? xmlRow = default, + bool? skipHeaderRow = default, + bool? skipHidden = default, + bool? skipEmpty = default, + bool? simplified = default, + string? view = default, + bool? skipFailedPages = default, + string? feedTitle = default, + string? feedDescription = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get the default dataset items from an Actor's last run
+ /// Returns data stored in the default dataset of the last Actor run in the desired format.
+ /// This endpoint is a shortcut that resolves the last run's `defaultDatasetId` and proxies to the
+ /// [Get dataset items](/api/v2/dataset-items-get) endpoint. + ///
+ /// + /// Example: compass~google-maps-extractor + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: json + /// + /// + /// Example: false + /// + /// + /// Example: 0 + /// + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: title,link + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue + /// + /// + /// Example: true + /// + /// + /// Example: true + /// + /// + /// Example: ; + /// + /// + /// Example: false + /// + /// + /// Example: items + /// + /// + /// Example: item + /// + /// + /// Example: true + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: overview + /// + /// + /// Example: false + /// + /// + /// Example: Latest posts from r/pasta + /// + /// + /// Example: Scraped forum posts + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordGetAsBytes.g.cs index 5733404..4398213 100644 --- a/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordGetAsBytes.g.cs @@ -94,6 +94,41 @@ public partial interface ILastActorRunSDefaultKeyValueStoreClient /// /// Example: true /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorRunsLastKeyValueStoreRecordGetAsBytesAsStreamAsResponseAsync( + string actorId, + string recordKey, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? signature = default, + bool? attachment = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get record from the default key-value store of an Actor's last run
+ /// Gets a value stored under a specific key in the default key-value store of the last Actor run.
+ /// This endpoint is a shortcut for getting the last run's `defaultKeyValueStoreId` and then using the
+ /// [Get key-value store record](/api/v2/key-value-store-record-get) endpoint. + ///
+ /// + /// Example: compass~google-maps-extractor + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: someKey + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// + /// Example: true + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordsGet.g.cs b/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordsGet.g.cs index 89de943..bbd053d 100644 --- a/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordsGet.g.cs +++ b/src/libs/Apify/Generated/Apify.ILastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordsGet.g.cs @@ -94,6 +94,41 @@ public partial interface ILastActorRunSDefaultKeyValueStoreClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorRunsLastKeyValueStoreRecordsGetAsStreamAsResponseAsync( + string actorId, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? collection = default, + string? prefix = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download records from the default key-value store of an Actor's last run
+ /// Downloads all records from the default key-value store of the last Actor run as a ZIP archive.
+ /// This endpoint is a shortcut for getting the last run's `defaultKeyValueStoreId` and then using the
+ /// [Download key-value store records](/api/v2/key-value-store-records-get) endpoint. + ///
+ /// + /// Example: compass~google-maps-extractor + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: my-collection + /// + /// + /// Example: my-prefix/ + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultDatasetClient.ActorTaskRunsLastDatasetItemsGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultDatasetClient.ActorTaskRunsLastDatasetItemsGetAsBytes.g.cs index f01fba6..d97f90c 100644 --- a/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultDatasetClient.ActorTaskRunsLastDatasetItemsGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultDatasetClient.ActorTaskRunsLastDatasetItemsGetAsBytes.g.cs @@ -319,6 +319,123 @@ public partial interface ILastActorTaskRunSDefaultDatasetClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorTaskRunsLastDatasetItemsGetAsBytesAsStreamAsResponseAsync( + string actorTaskId, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? format = default, + bool? clean = default, + double? offset = default, + double? limit = default, + string? fields = default, + string? outputFields = default, + string? omit = default, + string? unwind = default, + string? flatten = default, + bool? desc = default, + bool? attachment = default, + string? delimiter = default, + bool? bom = default, + string? xmlRoot = default, + string? xmlRow = default, + bool? skipHeaderRow = default, + bool? skipHidden = default, + bool? skipEmpty = default, + bool? simplified = default, + string? view = default, + bool? skipFailedPages = default, + string? feedTitle = default, + string? feedDescription = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get the default dataset items from an Actor task's last run
+ /// Returns data stored in the default dataset of the last Actor task run in the desired format.
+ /// This endpoint is a shortcut that resolves the last task run's `defaultDatasetId` and proxies to the
+ /// [Get dataset items](/api/v2/dataset-items-get) endpoint. + ///
+ /// + /// Example: janedoe~my-task + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: json + /// + /// + /// Example: false + /// + /// + /// Example: 0 + /// + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: title,link + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue + /// + /// + /// Example: true + /// + /// + /// Example: true + /// + /// + /// Example: ; + /// + /// + /// Example: false + /// + /// + /// Example: items + /// + /// + /// Example: item + /// + /// + /// Example: true + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: overview + /// + /// + /// Example: false + /// + /// + /// Example: Latest posts from r/pasta + /// + /// + /// Example: Scraped forum posts + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordGetAsBytes.g.cs index fd14a78..f65cab8 100644 --- a/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordGetAsBytes.g.cs @@ -94,6 +94,41 @@ public partial interface ILastActorTaskRunSDefaultKeyValueStoreClient /// /// Example: true /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorTaskRunsLastKeyValueStoreRecordGetAsBytesAsStreamAsResponseAsync( + string actorTaskId, + string recordKey, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? signature = default, + bool? attachment = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get record from the default key-value store of an Actor task's last run
+ /// Gets a value stored under a specific key in the default key-value store of the last Actor task run.
+ /// This endpoint is a shortcut for getting the last task run's `defaultKeyValueStoreId` and then using the
+ /// [Get key-value store record](/api/v2/key-value-store-record-get) endpoint. + ///
+ /// + /// Example: janedoe~my-task + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: someKey + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// + /// Example: true + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordsGet.g.cs b/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordsGet.g.cs index 2b4823e..d0a048f 100644 --- a/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordsGet.g.cs +++ b/src/libs/Apify/Generated/Apify.ILastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordsGet.g.cs @@ -94,6 +94,41 @@ public partial interface ILastActorTaskRunSDefaultKeyValueStoreClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ActorTaskRunsLastKeyValueStoreRecordsGetAsStreamAsResponseAsync( + string actorTaskId, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? collection = default, + string? prefix = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download records from the default key-value store of an Actor task's last run
+ /// Downloads all records from the default key-value store of the last Actor task run as a ZIP archive.
+ /// This endpoint is a shortcut for getting the last task run's `defaultKeyValueStoreId` and then using the
+ /// [Download key-value store records](/api/v2/key-value-store-records-get) endpoint. + ///
+ /// + /// Example: janedoe~my-task + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: my-collection + /// + /// + /// Example: my-prefix/ + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.IStorageDatasetsClient.DatasetItemsGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.IStorageDatasetsClient.DatasetItemsGetAsBytes.g.cs index f5563ca..60b2cb9 100644 --- a/src/libs/Apify/Generated/Apify.IStorageDatasetsClient.DatasetItemsGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.IStorageDatasetsClient.DatasetItemsGetAsBytes.g.cs @@ -666,6 +666,238 @@ public partial interface IStorageDatasetsClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> DatasetItemsGetAsBytesAsStreamAsResponseAsync( + string datasetId, + string? format = default, + bool? clean = default, + double? offset = default, + double? limit = default, + string? fields = default, + string? outputFields = default, + string? omit = default, + string? unwind = default, + string? flatten = default, + bool? desc = default, + bool? attachment = default, + string? delimiter = default, + bool? bom = default, + string? xmlRoot = default, + string? xmlRow = default, + bool? skipHeaderRow = default, + bool? skipHidden = default, + bool? skipEmpty = default, + bool? simplified = default, + string? view = default, + bool? skipFailedPages = default, + string? feedTitle = default, + string? feedDescription = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get dataset items
+ /// Returns data stored in the dataset in a desired format.
+ /// ### Response format
+ /// The format of the response depends on <code>format</code> query parameter.
+ /// The <code>format</code> parameter can have one of the following values:
+ /// <code>json</code>, <code>jsonl</code>, <code>xml</code>, <code>html</code>,
+ /// <code>csv</code>, <code>xlsx</code> and <code>rss</code>.
+ /// The following table describes how each format is treated.
+ /// <table>
+ /// <tr>
+ /// <th>Format</th>
+ /// <th>Items</th>
+ /// </tr>
+ /// <tr>
+ /// <td><code>json</code></td>
+ /// <td rowspan="3">The response is a JSON, JSONL or XML array of raw item objects.</td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>jsonl</code></td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>xml</code></td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>html</code></td>
+ /// <td rowspan="3">The response is a HTML, CSV or XLSX table, where columns correspond to the
+ /// properties of the item and rows correspond to each dataset item.</td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>csv</code></td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>xlsx</code></td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>rss</code></td>
+ /// <td colspan="2">The response is a RSS file. Each item is displayed as child elements of one
+ /// <code>&lt;item&gt;</code>.</td>
+ /// </tr>
+ /// </table>
+ /// Note that CSV, XLSX and HTML tables are limited to 2000 columns and the column names cannot be longer than 200 characters.
+ /// JSON, XML and RSS formats do not have such restrictions.
+ /// ### Hidden fields
+ /// The top-level fields starting with the `#` character are considered hidden.
+ /// These are useful to store debugging information and can be omitted from the output by providing the `skipHidden=1` or `clean=1` query parameters.
+ /// For example, if you store the following object to the dataset:
+ /// ```
+ /// {
+ /// productName: "iPhone Xs",
+ /// description: "Welcome to the big screens."
+ /// #debug: {
+ /// url: "https://www.apple.com/lae/iphone-xs/",
+ /// crawledAt: "2019-01-21T16:06:03.683Z"
+ /// }
+ /// }
+ /// ```
+ /// The `#debug` field will be considered as hidden and can be omitted from the
+ /// results. This is useful to
+ /// provide nice cleaned data to end users, while keeping debugging info
+ /// available if needed. The Dataset object
+ /// returned by the API contains the number of such clean items in the`dataset.cleanItemCount` property.
+ /// ### XML format extension
+ /// When exporting results to XML or RSS formats, the names of object properties become XML tags and the corresponding values become tag's children. For example, the following JavaScript object:
+ /// ```
+ /// {
+ /// name: "Paul Newman",
+ /// address: [
+ /// { type: "home", street: "21st", city: "Chicago" },
+ /// { type: "office", street: null, city: null }
+ /// ]
+ /// }
+ /// ```
+ /// will be transformed to the following XML snippet:
+ /// ```
+ /// <name>Paul Newman</name>
+ /// <address>
+ /// <type>home</type>
+ /// <street>21st</street>
+ /// <city>Chicago</city>
+ /// </address>
+ /// <address>
+ /// <type>office</type>
+ /// <street/>
+ /// <city/>
+ /// </address>
+ /// ```
+ /// If the JavaScript object contains a property named `@` then its sub-properties are exported as attributes of the parent XML
+ /// element.
+ /// If the parent XML element does not have any child elements then its value is taken from a JavaScript object property named `#`.
+ /// For example, the following JavaScript object:
+ /// ```
+ /// {
+ /// "address": [{
+ /// "@": {
+ /// "type": "home"
+ /// },
+ /// "street": "21st",
+ /// "city": "Chicago"
+ /// },
+ /// {
+ /// "@": {
+ /// "type": "office"
+ /// },
+ /// "#": 'unknown'
+ /// }]
+ /// }
+ /// ```
+ /// will be transformed to the following XML snippet:
+ /// ```
+ /// <address type="home">
+ /// <street>21st</street>
+ /// <city>Chicago</city>
+ /// </address>
+ /// <address type="office">unknown</address>
+ /// ```
+ /// This feature is also useful to customize your RSS feeds generated for various websites.
+ /// By default the whole result is wrapped in a `<items>` element and each page object is wrapped in a `<item>` element.
+ /// You can change this using <code>xmlRoot</code> and <code>xmlRow</code> url parameters.
+ /// ### Pagination
+ /// The generated response supports [pagination](#/introduction/pagination).
+ /// The pagination is always performed with the granularity of a single item, regardless whether <code>unwind</code> parameter was provided.
+ /// By default, the **Items** in the response are sorted by the time they were stored to the database, therefore you can use pagination to incrementally fetch the items as they are being added.
+ /// No limit exists to how many items can be returned in one response.
+ /// If you specify `desc=1` query parameter, the results are returned in the reverse order than they were stored (i.e. from newest to oldest items).
+ /// Note that only the order of **Items** is reversed, but not the order of the `unwind` array elements. + ///
+ /// + /// Example: WkzbQMuFYuamGv3YF + /// + /// + /// Example: json + /// + /// + /// Example: false + /// + /// + /// Example: 0 + /// + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: title,link + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue + /// + /// + /// Example: true + /// + /// + /// Example: true + /// + /// + /// Example: ; + /// + /// + /// Example: false + /// + /// + /// Example: items + /// + /// + /// Example: item + /// + /// + /// Example: true + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: overview + /// + /// + /// Example: false + /// + /// + /// Example: Latest posts from r/pasta + /// + /// + /// Example: Scraped forum posts + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.IStorageKeyValueStoresClient.KeyValueStoreRecordGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.IStorageKeyValueStoresClient.KeyValueStoreRecordGetAsBytes.g.cs index afc21b2..4b97d7d 100644 --- a/src/libs/Apify/Generated/Apify.IStorageKeyValueStoresClient.KeyValueStoreRecordGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.IStorageKeyValueStoresClient.KeyValueStoreRecordGetAsBytes.g.cs @@ -102,6 +102,43 @@ public partial interface IStorageKeyValueStoresClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> KeyValueStoreRecordGetAsBytesAsStreamAsResponseAsync( + string storeId, + string recordKey, + bool? attachment = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get key-value store record
+ /// Gets a value stored in the key-value store under a specific key.
+ /// The response body has the same `Content-Encoding` header as it was set in
+ /// [Put record](#tag/Key-value-storesRecord/operation/keyValueStore_record_put).
+ /// If the request does not define the `Accept-Encoding` HTTP header with the
+ /// right encoding, the record will be decompressed.
+ /// Most HTTP clients support decompression by default. After using the HTTP
+ /// client with decompression support, the `Accept-Encoding` header is set by
+ /// the client and body is decompressed automatically.
+ /// Please note that for security reasons, Apify API can perform small modifications
+ /// to HTML documents before they are served via this endpoint. To fetch the raw HTML
+ /// content without any modifications, use the `attachment` query parameter. + ///
+ /// + /// Example: WkzbQMuFYuamGv3YF + /// + /// + /// Example: someKey + /// + /// + /// Example: true + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.IStorageKeyValueStoresClient.KeyValueStoreRecordsGet.g.cs b/src/libs/Apify/Generated/Apify.IStorageKeyValueStoresClient.KeyValueStoreRecordsGet.g.cs index a066761..9524ce7 100644 --- a/src/libs/Apify/Generated/Apify.IStorageKeyValueStoresClient.KeyValueStoreRecordsGet.g.cs +++ b/src/libs/Apify/Generated/Apify.IStorageKeyValueStoresClient.KeyValueStoreRecordsGet.g.cs @@ -78,6 +78,35 @@ public partial interface IStorageKeyValueStoresClient /// /// Example: 2wTI46Bg8qWQrV7tavlPI /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> KeyValueStoreRecordsGetAsStreamAsResponseAsync( + string storeId, + string? collection = default, + string? prefix = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Download key-value store records
+ /// Downloads all records from the key-value store as a ZIP archive.
+ /// Each record is stored as a separate file in the archive, with the filename equal to the record key.
+ /// You can optionally filter the records by `collection` or `prefix` to download only a subset of the store. + ///
+ /// + /// Example: WkzbQMuFYuamGv3YF + /// + /// + /// Example: my-collection + /// + /// + /// Example: my-prefix/ + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/Apify/Generated/Apify.LastActorRunSDefaultDatasetClient.ActorRunsLastDatasetItemsGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.LastActorRunSDefaultDatasetClient.ActorRunsLastDatasetItemsGetAsBytes.g.cs index c005f60..536bb2b 100644 --- a/src/libs/Apify/Generated/Apify.LastActorRunSDefaultDatasetClient.ActorRunsLastDatasetItemsGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.LastActorRunSDefaultDatasetClient.ActorRunsLastDatasetItemsGetAsBytes.g.cs @@ -968,6 +968,781 @@ partial void ProcessActorRunsLastDatasetItemsGetAsBytesResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Get the default dataset items from an Actor's last run
+ /// Returns data stored in the default dataset of the last Actor run in the desired format.
+ /// This endpoint is a shortcut that resolves the last run's `defaultDatasetId` and proxies to the
+ /// [Get dataset items](/api/v2/dataset-items-get) endpoint. + ///
+ /// + /// Example: compass~google-maps-extractor + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: json + /// + /// + /// Example: false + /// + /// + /// Example: 0 + /// + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: title,link + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue + /// + /// + /// Example: true + /// + /// + /// Example: true + /// + /// + /// Example: ; + /// + /// + /// Example: false + /// + /// + /// Example: items + /// + /// + /// Example: item + /// + /// + /// Example: true + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: overview + /// + /// + /// Example: false + /// + /// + /// Example: Latest posts from r/pasta + /// + /// + /// Example: Scraped forum posts + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorRunsLastDatasetItemsGetAsBytesAsStreamAsResponseAsync( + string actorId, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? format = default, + bool? clean = default, + double? offset = default, + double? limit = default, + string? fields = default, + string? outputFields = default, + string? omit = default, + string? unwind = default, + string? flatten = default, + bool? desc = default, + bool? attachment = default, + string? delimiter = default, + bool? bom = default, + string? xmlRoot = default, + string? xmlRow = default, + bool? skipHeaderRow = default, + bool? skipHidden = default, + bool? skipEmpty = default, + bool? simplified = default, + string? view = default, + bool? skipFailedPages = default, + string? feedTitle = default, + string? feedDescription = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorRunsLastDatasetItemsGetAsBytesArguments( + httpClient: HttpClient, + actorId: ref actorId, + status: ref status, + origin: ref origin, + format: ref format, + clean: ref clean, + offset: ref offset, + limit: ref limit, + fields: ref fields, + outputFields: ref outputFields, + omit: ref omit, + unwind: ref unwind, + flatten: ref flatten, + desc: ref desc, + attachment: ref attachment, + delimiter: ref delimiter, + bom: ref bom, + xmlRoot: ref xmlRoot, + xmlRow: ref xmlRow, + skipHeaderRow: ref skipHeaderRow, + skipHidden: ref skipHidden, + skipEmpty: ref skipEmpty, + simplified: ref simplified, + view: ref view, + skipFailedPages: ref skipFailedPages, + feedTitle: ref feedTitle, + feedDescription: ref feedDescription, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorRunsLastDatasetItemsGetAsBytesSecurityRequirements, + operationName: "ActorRunsLastDatasetItemsGetAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actors/{actorId}/runs/last/dataset/items", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status) + .AddOptionalParameter("origin", origin?.ToValueString()) + .AddOptionalParameter("format", format) + .AddOptionalParameter("clean", clean?.ToString().ToLowerInvariant()) + .AddOptionalParameter("offset", offset?.ToString()) + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("fields", fields) + .AddOptionalParameter("outputFields", outputFields) + .AddOptionalParameter("omit", omit) + .AddOptionalParameter("unwind", unwind) + .AddOptionalParameter("flatten", flatten) + .AddOptionalParameter("desc", desc?.ToString().ToLowerInvariant()) + .AddOptionalParameter("attachment", attachment?.ToString().ToLowerInvariant()) + .AddOptionalParameter("delimiter", delimiter) + .AddOptionalParameter("bom", bom?.ToString().ToLowerInvariant()) + .AddOptionalParameter("xmlRoot", xmlRoot) + .AddOptionalParameter("xmlRow", xmlRow) + .AddOptionalParameter("skipHeaderRow", skipHeaderRow?.ToString().ToLowerInvariant()) + .AddOptionalParameter("skipHidden", skipHidden?.ToString().ToLowerInvariant()) + .AddOptionalParameter("skipEmpty", skipEmpty?.ToString().ToLowerInvariant()) + .AddOptionalParameter("simplified", simplified?.ToString().ToLowerInvariant()) + .AddOptionalParameter("view", view) + .AddOptionalParameter("skipFailedPages", skipFailedPages?.ToString().ToLowerInvariant()) + .AddOptionalParameter("feedTitle", feedTitle) + .AddOptionalParameter("feedDescription", feedDescription) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorRunsLastDatasetItemsGetAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + actorId: actorId, + status: status, + origin: origin, + format: format, + clean: clean, + offset: offset, + limit: limit, + fields: fields, + outputFields: outputFields, + omit: omit, + unwind: unwind, + flatten: flatten, + desc: desc, + attachment: attachment, + delimiter: delimiter, + bom: bom, + xmlRoot: xmlRoot, + xmlRow: xmlRow, + skipHeaderRow: skipHeaderRow, + skipHidden: skipHidden, + skipEmpty: skipEmpty, + simplified: simplified, + view: view, + skipFailedPages: skipFailedPages, + feedTitle: feedTitle, + feedDescription: feedDescription, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastDatasetItemsGetAsBytes", + methodName: "ActorRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastDatasetItemsGetAsBytes", + methodName: "ActorRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastDatasetItemsGetAsBytes", + methodName: "ActorRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorRunsLastDatasetItemsGetAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastDatasetItemsGetAsBytes", + methodName: "ActorRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastDatasetItemsGetAsBytes", + methodName: "ActorRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Payment required - the user has exceeded their usage limit, does not have enough credits, or the request lacks authentication and payment credentials. + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Apify.ErrorResponse? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.LastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.LastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordGetAsBytes.g.cs index b002b19..880c6eb 100644 --- a/src/libs/Apify/Generated/Apify.LastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.LastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordGetAsBytes.g.cs @@ -709,6 +709,667 @@ partial void ProcessActorRunsLastKeyValueStoreRecordGetAsBytesResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Get record from the default key-value store of an Actor's last run
+ /// Gets a value stored under a specific key in the default key-value store of the last Actor run.
+ /// This endpoint is a shortcut for getting the last run's `defaultKeyValueStoreId` and then using the
+ /// [Get key-value store record](/api/v2/key-value-store-record-get) endpoint. + ///
+ /// + /// Example: compass~google-maps-extractor + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: someKey + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// + /// Example: true + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorRunsLastKeyValueStoreRecordGetAsBytesAsStreamAsResponseAsync( + string actorId, + string recordKey, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? signature = default, + bool? attachment = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorRunsLastKeyValueStoreRecordGetAsBytesArguments( + httpClient: HttpClient, + actorId: ref actorId, + status: ref status, + origin: ref origin, + recordKey: ref recordKey, + signature: ref signature, + attachment: ref attachment); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorRunsLastKeyValueStoreRecordGetAsBytesSecurityRequirements, + operationName: "ActorRunsLastKeyValueStoreRecordGetAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actors/{actorId}/runs/last/key-value-store/records/{recordKey}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status) + .AddOptionalParameter("origin", origin?.ToValueString()) + .AddOptionalParameter("signature", signature) + .AddOptionalParameter("attachment", attachment?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "*/*"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorRunsLastKeyValueStoreRecordGetAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + actorId: actorId, + status: status, + origin: origin, + recordKey: recordKey, + signature: signature, + attachment: attachment); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorRunsLastKeyValueStoreRecordGetAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 302) + { + string? __content_302 = null; + global::System.Exception? __exception_302 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_302 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_302 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_302, + responseBody: __content_302, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Payment required - the user has exceeded their usage limit, does not have enough credits, or the request lacks authentication and payment credentials. + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Apify.ErrorResponse? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.LastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordsGet.g.cs b/src/libs/Apify/Generated/Apify.LastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordsGet.g.cs index 43b479e..b2c940a 100644 --- a/src/libs/Apify/Generated/Apify.LastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordsGet.g.cs +++ b/src/libs/Apify/Generated/Apify.LastActorRunSDefaultKeyValueStoreClient.ActorRunsLastKeyValueStoreRecordsGet.g.cs @@ -637,6 +637,595 @@ partial void ProcessActorRunsLastKeyValueStoreRecordsGetResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Download records from the default key-value store of an Actor's last run
+ /// Downloads all records from the default key-value store of the last Actor run as a ZIP archive.
+ /// This endpoint is a shortcut for getting the last run's `defaultKeyValueStoreId` and then using the
+ /// [Download key-value store records](/api/v2/key-value-store-records-get) endpoint. + ///
+ /// + /// Example: compass~google-maps-extractor + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: my-collection + /// + /// + /// Example: my-prefix/ + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorRunsLastKeyValueStoreRecordsGetAsStreamAsResponseAsync( + string actorId, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? collection = default, + string? prefix = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorRunsLastKeyValueStoreRecordsGetArguments( + httpClient: HttpClient, + actorId: ref actorId, + status: ref status, + origin: ref origin, + collection: ref collection, + prefix: ref prefix, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorRunsLastKeyValueStoreRecordsGetSecurityRequirements, + operationName: "ActorRunsLastKeyValueStoreRecordsGetAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actors/{actorId}/runs/last/key-value-store/records", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status) + .AddOptionalParameter("origin", origin?.ToValueString()) + .AddOptionalParameter("collection", collection) + .AddOptionalParameter("prefix", prefix) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorRunsLastKeyValueStoreRecordsGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + actorId: actorId, + status: status, + origin: origin, + collection: collection, + prefix: prefix, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordsGet", + methodName: "ActorRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordsGet", + methodName: "ActorRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordsGet", + methodName: "ActorRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorRunsLastKeyValueStoreRecordsGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordsGet", + methodName: "ActorRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorRunsLastKeyValueStoreRecordsGet", + methodName: "ActorRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actors/{actorId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultDatasetClient.ActorTaskRunsLastDatasetItemsGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultDatasetClient.ActorTaskRunsLastDatasetItemsGetAsBytes.g.cs index 4748087..a295495 100644 --- a/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultDatasetClient.ActorTaskRunsLastDatasetItemsGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultDatasetClient.ActorTaskRunsLastDatasetItemsGetAsBytes.g.cs @@ -968,6 +968,781 @@ partial void ProcessActorTaskRunsLastDatasetItemsGetAsBytesResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Get the default dataset items from an Actor task's last run
+ /// Returns data stored in the default dataset of the last Actor task run in the desired format.
+ /// This endpoint is a shortcut that resolves the last task run's `defaultDatasetId` and proxies to the
+ /// [Get dataset items](/api/v2/dataset-items-get) endpoint. + ///
+ /// + /// Example: janedoe~my-task + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: json + /// + /// + /// Example: false + /// + /// + /// Example: 0 + /// + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: title,link + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue + /// + /// + /// Example: true + /// + /// + /// Example: true + /// + /// + /// Example: ; + /// + /// + /// Example: false + /// + /// + /// Example: items + /// + /// + /// Example: item + /// + /// + /// Example: true + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: overview + /// + /// + /// Example: false + /// + /// + /// Example: Latest posts from r/pasta + /// + /// + /// Example: Scraped forum posts + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorTaskRunsLastDatasetItemsGetAsBytesAsStreamAsResponseAsync( + string actorTaskId, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? format = default, + bool? clean = default, + double? offset = default, + double? limit = default, + string? fields = default, + string? outputFields = default, + string? omit = default, + string? unwind = default, + string? flatten = default, + bool? desc = default, + bool? attachment = default, + string? delimiter = default, + bool? bom = default, + string? xmlRoot = default, + string? xmlRow = default, + bool? skipHeaderRow = default, + bool? skipHidden = default, + bool? skipEmpty = default, + bool? simplified = default, + string? view = default, + bool? skipFailedPages = default, + string? feedTitle = default, + string? feedDescription = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorTaskRunsLastDatasetItemsGetAsBytesArguments( + httpClient: HttpClient, + actorTaskId: ref actorTaskId, + status: ref status, + origin: ref origin, + format: ref format, + clean: ref clean, + offset: ref offset, + limit: ref limit, + fields: ref fields, + outputFields: ref outputFields, + omit: ref omit, + unwind: ref unwind, + flatten: ref flatten, + desc: ref desc, + attachment: ref attachment, + delimiter: ref delimiter, + bom: ref bom, + xmlRoot: ref xmlRoot, + xmlRow: ref xmlRow, + skipHeaderRow: ref skipHeaderRow, + skipHidden: ref skipHidden, + skipEmpty: ref skipEmpty, + simplified: ref simplified, + view: ref view, + skipFailedPages: ref skipFailedPages, + feedTitle: ref feedTitle, + feedDescription: ref feedDescription, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorTaskRunsLastDatasetItemsGetAsBytesSecurityRequirements, + operationName: "ActorTaskRunsLastDatasetItemsGetAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actor-tasks/{actorTaskId}/runs/last/dataset/items", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status) + .AddOptionalParameter("origin", origin?.ToValueString()) + .AddOptionalParameter("format", format) + .AddOptionalParameter("clean", clean?.ToString().ToLowerInvariant()) + .AddOptionalParameter("offset", offset?.ToString()) + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("fields", fields) + .AddOptionalParameter("outputFields", outputFields) + .AddOptionalParameter("omit", omit) + .AddOptionalParameter("unwind", unwind) + .AddOptionalParameter("flatten", flatten) + .AddOptionalParameter("desc", desc?.ToString().ToLowerInvariant()) + .AddOptionalParameter("attachment", attachment?.ToString().ToLowerInvariant()) + .AddOptionalParameter("delimiter", delimiter) + .AddOptionalParameter("bom", bom?.ToString().ToLowerInvariant()) + .AddOptionalParameter("xmlRoot", xmlRoot) + .AddOptionalParameter("xmlRow", xmlRow) + .AddOptionalParameter("skipHeaderRow", skipHeaderRow?.ToString().ToLowerInvariant()) + .AddOptionalParameter("skipHidden", skipHidden?.ToString().ToLowerInvariant()) + .AddOptionalParameter("skipEmpty", skipEmpty?.ToString().ToLowerInvariant()) + .AddOptionalParameter("simplified", simplified?.ToString().ToLowerInvariant()) + .AddOptionalParameter("view", view) + .AddOptionalParameter("skipFailedPages", skipFailedPages?.ToString().ToLowerInvariant()) + .AddOptionalParameter("feedTitle", feedTitle) + .AddOptionalParameter("feedDescription", feedDescription) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorTaskRunsLastDatasetItemsGetAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + actorTaskId: actorTaskId, + status: status, + origin: origin, + format: format, + clean: clean, + offset: offset, + limit: limit, + fields: fields, + outputFields: outputFields, + omit: omit, + unwind: unwind, + flatten: flatten, + desc: desc, + attachment: attachment, + delimiter: delimiter, + bom: bom, + xmlRoot: xmlRoot, + xmlRow: xmlRow, + skipHeaderRow: skipHeaderRow, + skipHidden: skipHidden, + skipEmpty: skipEmpty, + simplified: simplified, + view: view, + skipFailedPages: skipFailedPages, + feedTitle: feedTitle, + feedDescription: feedDescription, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastDatasetItemsGetAsBytes", + methodName: "ActorTaskRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastDatasetItemsGetAsBytes", + methodName: "ActorTaskRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastDatasetItemsGetAsBytes", + methodName: "ActorTaskRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorTaskRunsLastDatasetItemsGetAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastDatasetItemsGetAsBytes", + methodName: "ActorTaskRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastDatasetItemsGetAsBytes", + methodName: "ActorTaskRunsLastDatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/dataset/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Payment required - the user has exceeded their usage limit, does not have enough credits, or the request lacks authentication and payment credentials. + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Apify.ErrorResponse? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordGetAsBytes.g.cs index f5ce300..968e75f 100644 --- a/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordGetAsBytes.g.cs @@ -709,6 +709,667 @@ partial void ProcessActorTaskRunsLastKeyValueStoreRecordGetAsBytesResponseConten return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Get record from the default key-value store of an Actor task's last run
+ /// Gets a value stored under a specific key in the default key-value store of the last Actor task run.
+ /// This endpoint is a shortcut for getting the last task run's `defaultKeyValueStoreId` and then using the
+ /// [Get key-value store record](/api/v2/key-value-store-record-get) endpoint. + ///
+ /// + /// Example: janedoe~my-task + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: someKey + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// + /// Example: true + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorTaskRunsLastKeyValueStoreRecordGetAsBytesAsStreamAsResponseAsync( + string actorTaskId, + string recordKey, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? signature = default, + bool? attachment = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorTaskRunsLastKeyValueStoreRecordGetAsBytesArguments( + httpClient: HttpClient, + actorTaskId: ref actorTaskId, + status: ref status, + origin: ref origin, + recordKey: ref recordKey, + signature: ref signature, + attachment: ref attachment); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorTaskRunsLastKeyValueStoreRecordGetAsBytesSecurityRequirements, + operationName: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records/{recordKey}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status) + .AddOptionalParameter("origin", origin?.ToValueString()) + .AddOptionalParameter("signature", signature) + .AddOptionalParameter("attachment", attachment?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "*/*"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorTaskRunsLastKeyValueStoreRecordGetAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + actorTaskId: actorTaskId, + status: status, + origin: origin, + recordKey: recordKey, + signature: signature, + attachment: attachment); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorTaskRunsLastKeyValueStoreRecordGetAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytes", + methodName: "ActorTaskRunsLastKeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 302) + { + string? __content_302 = null; + global::System.Exception? __exception_302 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_302 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_302 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_302, + responseBody: __content_302, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Payment required - the user has exceeded their usage limit, does not have enough credits, or the request lacks authentication and payment credentials. + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Apify.ErrorResponse? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordsGet.g.cs b/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordsGet.g.cs index 42b7ade..df1d537 100644 --- a/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordsGet.g.cs +++ b/src/libs/Apify/Generated/Apify.LastActorTaskRunSDefaultKeyValueStoreClient.ActorTaskRunsLastKeyValueStoreRecordsGet.g.cs @@ -637,6 +637,595 @@ partial void ProcessActorTaskRunsLastKeyValueStoreRecordsGetResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Download records from the default key-value store of an Actor task's last run
+ /// Downloads all records from the default key-value store of the last Actor task run as a ZIP archive.
+ /// This endpoint is a shortcut for getting the last task run's `defaultKeyValueStoreId` and then using the
+ /// [Download key-value store records](/api/v2/key-value-store-records-get) endpoint. + ///
+ /// + /// Example: janedoe~my-task + /// + /// + /// Example: SUCCEEDED + /// + /// + /// + /// Example: my-collection + /// + /// + /// Example: my-prefix/ + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ActorTaskRunsLastKeyValueStoreRecordsGetAsStreamAsResponseAsync( + string actorTaskId, + string? status = default, + global::Apify.RunOrigin? origin = default, + string? collection = default, + string? prefix = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareActorTaskRunsLastKeyValueStoreRecordsGetArguments( + httpClient: HttpClient, + actorTaskId: ref actorTaskId, + status: ref status, + origin: ref origin, + collection: ref collection, + prefix: ref prefix, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_ActorTaskRunsLastKeyValueStoreRecordsGetSecurityRequirements, + operationName: "ActorTaskRunsLastKeyValueStoreRecordsGetAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("status", status) + .AddOptionalParameter("origin", origin?.ToValueString()) + .AddOptionalParameter("collection", collection) + .AddOptionalParameter("prefix", prefix) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareActorTaskRunsLastKeyValueStoreRecordsGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + actorTaskId: actorTaskId, + status: status, + origin: origin, + collection: collection, + prefix: prefix, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordsGet", + methodName: "ActorTaskRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordsGet", + methodName: "ActorTaskRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordsGet", + methodName: "ActorTaskRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessActorTaskRunsLastKeyValueStoreRecordsGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordsGet", + methodName: "ActorTaskRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ActorTaskRunsLastKeyValueStoreRecordsGet", + methodName: "ActorTaskRunsLastKeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.ResponseStream.g.cs b/src/libs/Apify/Generated/Apify.ResponseStream.g.cs index 840ecad..bf87b89 100644 --- a/src/libs/Apify/Generated/Apify.ResponseStream.g.cs +++ b/src/libs/Apify/Generated/Apify.ResponseStream.g.cs @@ -7,7 +7,7 @@ internal sealed class ResponseStream : global::System.IO.Stream { private readonly global::System.Net.Http.HttpResponseMessage _response; private readonly global::System.IO.Stream _stream; - private bool _disposed; + private int _disposed; public ResponseStream( global::System.Net.Http.HttpResponseMessage response, @@ -47,21 +47,51 @@ public override int WriteTimeout global::System.Threading.CancellationToken cancellationToken) => _stream.FlushAsync(cancellationToken); - public override int Read(byte[] buffer, int offset, int count) => - _stream.Read(buffer, offset, count); + public override int Read(byte[] buffer, int offset, int count) + { + try + { + return _stream.Read(buffer, offset, count); + } + catch + { + Dispose(); + throw; + } + } - public override global::System.Threading.Tasks.Task ReadAsync( + public override async global::System.Threading.Tasks.Task ReadAsync( byte[] buffer, int offset, int count, - global::System.Threading.CancellationToken cancellationToken) => - _stream.ReadAsync(buffer, offset, count, cancellationToken); + global::System.Threading.CancellationToken cancellationToken) + { + try + { + return await _stream.ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false); + } + catch + { + Dispose(); + throw; + } + } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER - public override global::System.Threading.Tasks.ValueTask ReadAsync( + public override async global::System.Threading.Tasks.ValueTask ReadAsync( global::System.Memory buffer, - global::System.Threading.CancellationToken cancellationToken = default) => - _stream.ReadAsync(buffer, cancellationToken); + global::System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await _stream.ReadAsync(buffer, cancellationToken).ConfigureAwait(false); + } + catch + { + Dispose(); + throw; + } + } #endif public override long Seek(long offset, global::System.IO.SeekOrigin origin) => @@ -89,10 +119,9 @@ public override void Write(byte[] buffer, int offset, int count) => protected override void Dispose(bool disposing) { - if (!_disposed && disposing) + if (disposing && global::System.Threading.Interlocked.Exchange(ref _disposed, 1) == 0) { - _disposed = true; - _stream.Dispose(); + // The response content owns the underlying stream; disposing both would close it twice. _response.Dispose(); } @@ -100,17 +129,10 @@ protected override void Dispose(bool disposing) } #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_0_OR_GREATER || NET5_0_OR_GREATER - public override async global::System.Threading.Tasks.ValueTask DisposeAsync() + public override global::System.Threading.Tasks.ValueTask DisposeAsync() { - if (_disposed) - { - return; - } - - _disposed = true; - await _stream.DisposeAsync().ConfigureAwait(false); - _response.Dispose(); - await base.DisposeAsync().ConfigureAwait(false); + Dispose(); + return default; } #endif } diff --git a/src/libs/Apify/Generated/Apify.StorageDatasetsClient.DatasetItemsGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.StorageDatasetsClient.DatasetItemsGetAsBytes.g.cs index 7022022..d6a7201 100644 --- a/src/libs/Apify/Generated/Apify.StorageDatasetsClient.DatasetItemsGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.StorageDatasetsClient.DatasetItemsGetAsBytes.g.cs @@ -1186,6 +1186,890 @@ partial void ProcessDatasetItemsGetAsBytesResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Get dataset items
+ /// Returns data stored in the dataset in a desired format.
+ /// ### Response format
+ /// The format of the response depends on <code>format</code> query parameter.
+ /// The <code>format</code> parameter can have one of the following values:
+ /// <code>json</code>, <code>jsonl</code>, <code>xml</code>, <code>html</code>,
+ /// <code>csv</code>, <code>xlsx</code> and <code>rss</code>.
+ /// The following table describes how each format is treated.
+ /// <table>
+ /// <tr>
+ /// <th>Format</th>
+ /// <th>Items</th>
+ /// </tr>
+ /// <tr>
+ /// <td><code>json</code></td>
+ /// <td rowspan="3">The response is a JSON, JSONL or XML array of raw item objects.</td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>jsonl</code></td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>xml</code></td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>html</code></td>
+ /// <td rowspan="3">The response is a HTML, CSV or XLSX table, where columns correspond to the
+ /// properties of the item and rows correspond to each dataset item.</td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>csv</code></td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>xlsx</code></td>
+ /// </tr>
+ /// <tr>
+ /// <td><code>rss</code></td>
+ /// <td colspan="2">The response is a RSS file. Each item is displayed as child elements of one
+ /// <code>&lt;item&gt;</code>.</td>
+ /// </tr>
+ /// </table>
+ /// Note that CSV, XLSX and HTML tables are limited to 2000 columns and the column names cannot be longer than 200 characters.
+ /// JSON, XML and RSS formats do not have such restrictions.
+ /// ### Hidden fields
+ /// The top-level fields starting with the `#` character are considered hidden.
+ /// These are useful to store debugging information and can be omitted from the output by providing the `skipHidden=1` or `clean=1` query parameters.
+ /// For example, if you store the following object to the dataset:
+ /// ```
+ /// {
+ /// productName: "iPhone Xs",
+ /// description: "Welcome to the big screens."
+ /// #debug: {
+ /// url: "https://www.apple.com/lae/iphone-xs/",
+ /// crawledAt: "2019-01-21T16:06:03.683Z"
+ /// }
+ /// }
+ /// ```
+ /// The `#debug` field will be considered as hidden and can be omitted from the
+ /// results. This is useful to
+ /// provide nice cleaned data to end users, while keeping debugging info
+ /// available if needed. The Dataset object
+ /// returned by the API contains the number of such clean items in the`dataset.cleanItemCount` property.
+ /// ### XML format extension
+ /// When exporting results to XML or RSS formats, the names of object properties become XML tags and the corresponding values become tag's children. For example, the following JavaScript object:
+ /// ```
+ /// {
+ /// name: "Paul Newman",
+ /// address: [
+ /// { type: "home", street: "21st", city: "Chicago" },
+ /// { type: "office", street: null, city: null }
+ /// ]
+ /// }
+ /// ```
+ /// will be transformed to the following XML snippet:
+ /// ```
+ /// <name>Paul Newman</name>
+ /// <address>
+ /// <type>home</type>
+ /// <street>21st</street>
+ /// <city>Chicago</city>
+ /// </address>
+ /// <address>
+ /// <type>office</type>
+ /// <street/>
+ /// <city/>
+ /// </address>
+ /// ```
+ /// If the JavaScript object contains a property named `@` then its sub-properties are exported as attributes of the parent XML
+ /// element.
+ /// If the parent XML element does not have any child elements then its value is taken from a JavaScript object property named `#`.
+ /// For example, the following JavaScript object:
+ /// ```
+ /// {
+ /// "address": [{
+ /// "@": {
+ /// "type": "home"
+ /// },
+ /// "street": "21st",
+ /// "city": "Chicago"
+ /// },
+ /// {
+ /// "@": {
+ /// "type": "office"
+ /// },
+ /// "#": 'unknown'
+ /// }]
+ /// }
+ /// ```
+ /// will be transformed to the following XML snippet:
+ /// ```
+ /// <address type="home">
+ /// <street>21st</street>
+ /// <city>Chicago</city>
+ /// </address>
+ /// <address type="office">unknown</address>
+ /// ```
+ /// This feature is also useful to customize your RSS feeds generated for various websites.
+ /// By default the whole result is wrapped in a `<items>` element and each page object is wrapped in a `<item>` element.
+ /// You can change this using <code>xmlRoot</code> and <code>xmlRow</code> url parameters.
+ /// ### Pagination
+ /// The generated response supports [pagination](#/introduction/pagination).
+ /// The pagination is always performed with the granularity of a single item, regardless whether <code>unwind</code> parameter was provided.
+ /// By default, the **Items** in the response are sorted by the time they were stored to the database, therefore you can use pagination to incrementally fetch the items as they are being added.
+ /// No limit exists to how many items can be returned in one response.
+ /// If you specify `desc=1` query parameter, the results are returned in the reverse order than they were stored (i.e. from newest to oldest items).
+ /// Note that only the order of **Items** is reversed, but not the order of the `unwind` array elements. + ///
+ /// + /// Example: WkzbQMuFYuamGv3YF + /// + /// + /// Example: json + /// + /// + /// Example: false + /// + /// + /// Example: 0 + /// + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: title,link + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue,myOtherValue + /// + /// + /// Example: myValue + /// + /// + /// Example: true + /// + /// + /// Example: true + /// + /// + /// Example: ; + /// + /// + /// Example: false + /// + /// + /// Example: items + /// + /// + /// Example: item + /// + /// + /// Example: true + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: false + /// + /// + /// Example: overview + /// + /// + /// Example: false + /// + /// + /// Example: Latest posts from r/pasta + /// + /// + /// Example: Scraped forum posts + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> DatasetItemsGetAsBytesAsStreamAsResponseAsync( + string datasetId, + string? format = default, + bool? clean = default, + double? offset = default, + double? limit = default, + string? fields = default, + string? outputFields = default, + string? omit = default, + string? unwind = default, + string? flatten = default, + bool? desc = default, + bool? attachment = default, + string? delimiter = default, + bool? bom = default, + string? xmlRoot = default, + string? xmlRow = default, + bool? skipHeaderRow = default, + bool? skipHidden = default, + bool? skipEmpty = default, + bool? simplified = default, + string? view = default, + bool? skipFailedPages = default, + string? feedTitle = default, + string? feedDescription = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareDatasetItemsGetAsBytesArguments( + httpClient: HttpClient, + datasetId: ref datasetId, + format: ref format, + clean: ref clean, + offset: ref offset, + limit: ref limit, + fields: ref fields, + outputFields: ref outputFields, + omit: ref omit, + unwind: ref unwind, + flatten: ref flatten, + desc: ref desc, + attachment: ref attachment, + delimiter: ref delimiter, + bom: ref bom, + xmlRoot: ref xmlRoot, + xmlRow: ref xmlRow, + skipHeaderRow: ref skipHeaderRow, + skipHidden: ref skipHidden, + skipEmpty: ref skipEmpty, + simplified: ref simplified, + view: ref view, + skipFailedPages: ref skipFailedPages, + feedTitle: ref feedTitle, + feedDescription: ref feedDescription, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_DatasetItemsGetAsBytesSecurityRequirements, + operationName: "DatasetItemsGetAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/datasets/{datasetId}/items", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("format", format) + .AddOptionalParameter("clean", clean?.ToString().ToLowerInvariant()) + .AddOptionalParameter("offset", offset?.ToString()) + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("fields", fields) + .AddOptionalParameter("outputFields", outputFields) + .AddOptionalParameter("omit", omit) + .AddOptionalParameter("unwind", unwind) + .AddOptionalParameter("flatten", flatten) + .AddOptionalParameter("desc", desc?.ToString().ToLowerInvariant()) + .AddOptionalParameter("attachment", attachment?.ToString().ToLowerInvariant()) + .AddOptionalParameter("delimiter", delimiter) + .AddOptionalParameter("bom", bom?.ToString().ToLowerInvariant()) + .AddOptionalParameter("xmlRoot", xmlRoot) + .AddOptionalParameter("xmlRow", xmlRow) + .AddOptionalParameter("skipHeaderRow", skipHeaderRow?.ToString().ToLowerInvariant()) + .AddOptionalParameter("skipHidden", skipHidden?.ToString().ToLowerInvariant()) + .AddOptionalParameter("skipEmpty", skipEmpty?.ToString().ToLowerInvariant()) + .AddOptionalParameter("simplified", simplified?.ToString().ToLowerInvariant()) + .AddOptionalParameter("view", view) + .AddOptionalParameter("skipFailedPages", skipFailedPages?.ToString().ToLowerInvariant()) + .AddOptionalParameter("feedTitle", feedTitle) + .AddOptionalParameter("feedDescription", feedDescription) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDatasetItemsGetAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + datasetId: datasetId, + format: format, + clean: clean, + offset: offset, + limit: limit, + fields: fields, + outputFields: outputFields, + omit: omit, + unwind: unwind, + flatten: flatten, + desc: desc, + attachment: attachment, + delimiter: delimiter, + bom: bom, + xmlRoot: xmlRoot, + xmlRow: xmlRow, + skipHeaderRow: skipHeaderRow, + skipHidden: skipHidden, + skipEmpty: skipEmpty, + simplified: simplified, + view: view, + skipFailedPages: skipFailedPages, + feedTitle: feedTitle, + feedDescription: feedDescription, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DatasetItemsGetAsBytes", + methodName: "DatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/datasets/{datasetId}/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DatasetItemsGetAsBytes", + methodName: "DatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/datasets/{datasetId}/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DatasetItemsGetAsBytes", + methodName: "DatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/datasets/{datasetId}/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDatasetItemsGetAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DatasetItemsGetAsBytes", + methodName: "DatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/datasets/{datasetId}/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DatasetItemsGetAsBytes", + methodName: "DatasetItemsGetAsBytesAsync", + pathTemplate: "$\"/v2/datasets/{datasetId}/items\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Payment required - the user has exceeded their usage limit, does not have enough credits, or the request lacks authentication and payment credentials. + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Apify.ErrorResponse? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.StorageKeyValueStoresClient.KeyValueStoreRecordGetAsBytes.g.cs b/src/libs/Apify/Generated/Apify.StorageKeyValueStoresClient.KeyValueStoreRecordGetAsBytes.g.cs index b258362..cbcbec1 100644 --- a/src/libs/Apify/Generated/Apify.StorageKeyValueStoresClient.KeyValueStoreRecordGetAsBytes.g.cs +++ b/src/libs/Apify/Generated/Apify.StorageKeyValueStoresClient.KeyValueStoreRecordGetAsBytes.g.cs @@ -701,6 +701,663 @@ partial void ProcessKeyValueStoreRecordGetAsBytesResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Get key-value store record
+ /// Gets a value stored in the key-value store under a specific key.
+ /// The response body has the same `Content-Encoding` header as it was set in
+ /// [Put record](#tag/Key-value-storesRecord/operation/keyValueStore_record_put).
+ /// If the request does not define the `Accept-Encoding` HTTP header with the
+ /// right encoding, the record will be decompressed.
+ /// Most HTTP clients support decompression by default. After using the HTTP
+ /// client with decompression support, the `Accept-Encoding` header is set by
+ /// the client and body is decompressed automatically.
+ /// Please note that for security reasons, Apify API can perform small modifications
+ /// to HTML documents before they are served via this endpoint. To fetch the raw HTML
+ /// content without any modifications, use the `attachment` query parameter. + ///
+ /// + /// Example: WkzbQMuFYuamGv3YF + /// + /// + /// Example: someKey + /// + /// + /// Example: true + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> KeyValueStoreRecordGetAsBytesAsStreamAsResponseAsync( + string storeId, + string recordKey, + bool? attachment = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareKeyValueStoreRecordGetAsBytesArguments( + httpClient: HttpClient, + storeId: ref storeId, + recordKey: ref recordKey, + attachment: ref attachment, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_KeyValueStoreRecordGetAsBytesSecurityRequirements, + operationName: "KeyValueStoreRecordGetAsBytesAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/key-value-stores/{storeId}/records/{recordKey}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("attachment", attachment?.ToString().ToLowerInvariant()) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + __httpRequest.Headers.TryAddWithoutValidation( + "Accept", + "*/*"); + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareKeyValueStoreRecordGetAsBytesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeId: storeId, + recordKey: recordKey, + attachment: attachment, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordGetAsBytes", + methodName: "KeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordGetAsBytes", + methodName: "KeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordGetAsBytes", + methodName: "KeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessKeyValueStoreRecordGetAsBytesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordGetAsBytes", + methodName: "KeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordGetAsBytes", + methodName: "KeyValueStoreRecordGetAsBytesAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records/{recordKey}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 302) + { + string? __content_302 = null; + global::System.Exception? __exception_302 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_302 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_302 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_302 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_302, + responseBody: __content_302, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Payment required - the user has exceeded their usage limit, does not have enough credits, or the request lacks authentication and payment credentials. + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + global::Apify.ErrorResponse? __value_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_402 = global::Apify.ErrorResponse.FromJson(__content_402, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + responseBody: __content_402, + responseObject: __value_402, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null; diff --git a/src/libs/Apify/Generated/Apify.StorageKeyValueStoresClient.KeyValueStoreRecordsGet.g.cs b/src/libs/Apify/Generated/Apify.StorageKeyValueStoresClient.KeyValueStoreRecordsGet.g.cs index 5903fe8..45ca620 100644 --- a/src/libs/Apify/Generated/Apify.StorageKeyValueStoresClient.KeyValueStoreRecordsGet.g.cs +++ b/src/libs/Apify/Generated/Apify.StorageKeyValueStoresClient.KeyValueStoreRecordsGet.g.cs @@ -613,6 +613,583 @@ partial void ProcessKeyValueStoreRecordsGetResponseContent( return new global::Apify.ResponseStream(__response, __content); } + catch (global::System.OperationCanceledException) + { + throw; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + } + catch + { + __response.Dispose(); + throw; + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Download key-value store records
+ /// Downloads all records from the key-value store as a ZIP archive.
+ /// Each record is stored as a separate file in the archive, with the filename equal to the record key.
+ /// You can optionally filter the records by `collection` or `prefix` to download only a subset of the store. + ///
+ /// + /// Example: WkzbQMuFYuamGv3YF + /// + /// + /// Example: my-collection + /// + /// + /// Example: my-prefix/ + /// + /// + /// Example: 2wTI46Bg8qWQrV7tavlPI + /// + /// The response metadata and an unbuffered body stream. The caller must dispose Body to release the HTTP response. + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> KeyValueStoreRecordsGetAsStreamAsResponseAsync( + string storeId, + string? collection = default, + string? prefix = default, + string? signature = default, + global::Apify.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareKeyValueStoreRecordsGetArguments( + httpClient: HttpClient, + storeId: ref storeId, + collection: ref collection, + prefix: ref prefix, + signature: ref signature); + + + var __authorizations = global::Apify.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_KeyValueStoreRecordsGetSecurityRequirements, + operationName: "KeyValueStoreRecordsGetAsync"); + + using var __timeoutCancellationTokenSource = global::Apify.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Apify.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Apify.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Apify.PathBuilder( + path: $"/v2/key-value-stores/{storeId}/records", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("collection", collection) + .AddOptionalParameter("prefix", prefix) + .AddOptionalParameter("signature", signature) + ; + var __path = __pathBuilder.ToString(); + __path = global::Apify.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::Apify.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareKeyValueStoreRecordsGetRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeId: storeId, + collection: collection, + prefix: prefix, + signature: signature); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Apify.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordsGet", + methodName: "KeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordsGet", + methodName: "KeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Apify.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Apify.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordsGet", + methodName: "KeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Apify.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + try + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessKeyValueStoreRecordsGetResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordsGet", + methodName: "KeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Apify.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Apify.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "KeyValueStoreRecordsGet", + methodName: "KeyValueStoreRecordsGetAsync", + pathTemplate: "$\"/v2/key-value-stores/{storeId}/records\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest ?? throw new global::System.InvalidOperationException("The HTTP request was not created before invoking a request hook."), + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Bad request - invalid input parameters or request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::Apify.ErrorResponse? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::Apify.ErrorResponse.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Unauthorized - authentication required or invalid token. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::Apify.ErrorResponse? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::Apify.ErrorResponse.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Forbidden - insufficient permissions to perform this action. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::Apify.ErrorResponse? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::Apify.ErrorResponse.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Not found - the requested resource does not exist. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::Apify.ErrorResponse? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::Apify.ErrorResponse.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Method not allowed. + if ((int)__response.StatusCode == 405) + { + string? __content_405 = null; + global::System.Exception? __exception_405 = null; + global::Apify.ErrorResponse? __value_405 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + else + { + __content_405 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_405 = global::Apify.ErrorResponse.FromJson(__content_405, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_405 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_405 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_405, + responseBody: __content_405, + responseObject: __value_405, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Too many requests - rate limit exceeded. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::Apify.ErrorResponse? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::Apify.ErrorResponse.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::Apify.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + try + { + __response.EnsureSuccessStatusCode(); + + var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return new global::Apify.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Apify.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: new global::Apify.ResponseStream(__response, __content)); + } + catch (global::System.OperationCanceledException) + { + throw; + } catch (global::System.Exception __ex) { string? __content = null;