Skip to content

[Backport 8.2] Add support for task APIs. #7569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ internal static class ApiUrlLookup
internal static ApiUrls SqlGetAsync = new ApiUrls(new[] { "/_sql/async/{id}" });
internal static ApiUrls SqlGetAsyncStatus = new ApiUrls(new[] { "/_sql/async/status/{id}" });
internal static ApiUrls SqlQuery = new ApiUrls(new[] { "/_sql" });
internal static ApiUrls TasksCancel = new ApiUrls(new[] { "/_tasks/_cancel", "/_tasks/{task_id}/_cancel" });
internal static ApiUrls TasksGet = new ApiUrls(new[] { "/_tasks/{task_id}" });
internal static ApiUrls TasksList = new ApiUrls(new[] { "/_tasks" });
internal static ApiUrls NoNamespaceTermsEnum = new ApiUrls(new[] { "/{index}/_terms_enum" });
internal static ApiUrls NoNamespaceUpdateByQuery = new ApiUrls(new[] { "/{index}/_update_by_query" });
internal static ApiUrls NoNamespaceUpdateByQueryRethrottle = new ApiUrls(new[] { "/_update_by_query/{task_id}/_rethrottle" });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Tasks;

public sealed class CancelRequestParameters : RequestParameters
{
/// <summary>
/// <para>A comma-separated list of actions that should be cancelled. Leave empty to cancel all.</para>
/// </summary>
public ICollection<string>? Actions { get => Q<ICollection<string>?>("actions"); set => Q("actions", value); }

/// <summary>
/// <para>A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes</para>
/// </summary>
public ICollection<string>? Nodes { get => Q<ICollection<string>?>("nodes"); set => Q("nodes", value); }

/// <summary>
/// <para>Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.</para>
/// </summary>
public string? ParentTaskId { get => Q<string?>("parent_task_id"); set => Q("parent_task_id", value); }

/// <summary>
/// <para>Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false</para>
/// </summary>
public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }
}

/// <summary>
/// EXPERIMENTAL! May change in ways that are not backwards compatible or be removed entirely.
/// <para>Cancels a task, if it can be cancelled through an API.</para>
/// </summary>
public sealed partial class CancelRequest : PlainRequest<CancelRequestParameters>
{
public CancelRequest()
{
}

public CancelRequest(Elastic.Clients.Elasticsearch.TaskId? task_id) : base(r => r.Optional("task_id", task_id))
{
}

internal override ApiUrls ApiUrls => ApiUrlLookup.TasksCancel;

protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

internal override bool SupportsBody => false;

/// <summary>
/// <para>A comma-separated list of actions that should be cancelled. Leave empty to cancel all.</para>
/// </summary>
[JsonIgnore]
public ICollection<string>? Actions { get => Q<ICollection<string>?>("actions"); set => Q("actions", value); }

/// <summary>
/// <para>A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes</para>
/// </summary>
[JsonIgnore]
public ICollection<string>? Nodes { get => Q<ICollection<string>?>("nodes"); set => Q("nodes", value); }

/// <summary>
/// <para>Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all.</para>
/// </summary>
[JsonIgnore]
public string? ParentTaskId { get => Q<string?>("parent_task_id"); set => Q("parent_task_id", value); }

/// <summary>
/// <para>Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false</para>
/// </summary>
[JsonIgnore]
public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }
}

/// <summary>
/// EXPERIMENTAL! May change in ways that are not backwards compatible or be removed entirely.
/// <para>Cancels a task, if it can be cancelled through an API.</para>
/// </summary>
public sealed partial class CancelRequestDescriptor : RequestDescriptor<CancelRequestDescriptor, CancelRequestParameters>
{
internal CancelRequestDescriptor(Action<CancelRequestDescriptor> configure) => configure.Invoke(this);

public CancelRequestDescriptor()
{
}

internal override ApiUrls ApiUrls => ApiUrlLookup.TasksCancel;

protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

internal override bool SupportsBody => false;

public CancelRequestDescriptor Actions(ICollection<string>? actions) => Qs("actions", actions);
public CancelRequestDescriptor Nodes(ICollection<string>? nodes) => Qs("nodes", nodes);
public CancelRequestDescriptor ParentTaskId(string? parentTaskId) => Qs("parent_task_id", parentTaskId);
public CancelRequestDescriptor WaitForCompletion(bool? waitForCompletion = true) => Qs("wait_for_completion", waitForCompletion);

public CancelRequestDescriptor TaskId(Elastic.Clients.Elasticsearch.TaskId? task_id)
{
RouteValues.Optional("task_id", task_id);
return Self;
}

protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport.Products.Elasticsearch;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Tasks;

/// <summary>
/// EXPERIMENTAL! May change in ways that are not backwards compatible or be removed entirely.
/// </summary>
public sealed partial class CancelResponse : ElasticsearchResponse
{
[JsonInclude, JsonPropertyName("node_failures")]
public IReadOnlyCollection<Elastic.Clients.Elasticsearch.ErrorCause>? NodeFailures { get; init; }

/// <summary>
/// <para>Task information grouped by node, if `group_by` was set to `node` (the default).</para>
/// </summary>
[JsonInclude, JsonPropertyName("nodes")]
public IReadOnlyDictionary<string, Elastic.Clients.Elasticsearch.Tasks.NodeTasks>? Nodes { get; init; }
[JsonInclude, JsonPropertyName("task_failures")]
public IReadOnlyCollection<Elastic.Clients.Elasticsearch.TaskFailure>? TaskFailures { get; init; }

/// <summary>
/// <para>Either a flat list of tasks if `group_by` was set to `none`, or grouped by parents if<br/>`group_by` was set to `parents`.</para>
/// </summary>
[JsonInclude, JsonPropertyName("tasks")]
public Elastic.Clients.Elasticsearch.Tasks.TaskInfos? Tasks { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Tasks;

public sealed class GetTasksRequestParameters : RequestParameters
{
/// <summary>
/// <para>Explicit operation timeout</para>
/// </summary>
public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

/// <summary>
/// <para>Wait for the matching tasks to complete (default: false)</para>
/// </summary>
public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }
}

/// <summary>
/// EXPERIMENTAL! May change in ways that are not backwards compatible or be removed entirely.
/// <para>Returns information about a task.</para>
/// </summary>
public sealed partial class GetTasksRequest : PlainRequest<GetTasksRequestParameters>
{
public GetTasksRequest(Elastic.Clients.Elasticsearch.Id task_id) : base(r => r.Required("task_id", task_id))
{
}

internal override ApiUrls ApiUrls => ApiUrlLookup.TasksGet;

protected override HttpMethod StaticHttpMethod => HttpMethod.GET;

internal override bool SupportsBody => false;

/// <summary>
/// <para>Explicit operation timeout</para>
/// </summary>
[JsonIgnore]
public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q<Elastic.Clients.Elasticsearch.Duration?>("timeout"); set => Q("timeout", value); }

/// <summary>
/// <para>Wait for the matching tasks to complete (default: false)</para>
/// </summary>
[JsonIgnore]
public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }
}

/// <summary>
/// EXPERIMENTAL! May change in ways that are not backwards compatible or be removed entirely.
/// <para>Returns information about a task.</para>
/// </summary>
public sealed partial class GetTasksRequestDescriptor : RequestDescriptor<GetTasksRequestDescriptor, GetTasksRequestParameters>
{
internal GetTasksRequestDescriptor(Action<GetTasksRequestDescriptor> configure) => configure.Invoke(this);

public GetTasksRequestDescriptor(Elastic.Clients.Elasticsearch.Id task_id) : base(r => r.Required("task_id", task_id))
{
}

internal GetTasksRequestDescriptor()
{
}

internal override ApiUrls ApiUrls => ApiUrlLookup.TasksGet;

protected override HttpMethod StaticHttpMethod => HttpMethod.GET;

internal override bool SupportsBody => false;

public GetTasksRequestDescriptor Timeout(Elastic.Clients.Elasticsearch.Duration? timeout) => Qs("timeout", timeout);
public GetTasksRequestDescriptor WaitForCompletion(bool? waitForCompletion = true) => Qs("wait_for_completion", waitForCompletion);

public GetTasksRequestDescriptor TaskId(Elastic.Clients.Elasticsearch.Id task_id)
{
RouteValues.Required("task_id", task_id);
return Self;
}

protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport.Products.Elasticsearch;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Tasks;

/// <summary>
/// EXPERIMENTAL! May change in ways that are not backwards compatible or be removed entirely.
/// </summary>
public sealed partial class GetTasksResponse : ElasticsearchResponse
{
[JsonInclude, JsonPropertyName("completed")]
public bool Completed { get; init; }
[JsonInclude, JsonPropertyName("response")]
public Elastic.Clients.Elasticsearch.Tasks.TaskStatus? Response { get; init; }
[JsonInclude, JsonPropertyName("task")]
public Elastic.Clients.Elasticsearch.Tasks.TaskInfo Task { get; init; }
}
Loading