Skip to content
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

Implement cat.transforms #4557

Merged
merged 2 commits into from
Apr 16, 2020
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
1 change: 0 additions & 1 deletion src/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public static class CodeConfiguration
"cat.ml_datafeeds.json",
"cat.ml_jobs.json",
"cat.ml_trained_models.json",
"cat.transforms.json",
"cluster.delete_component_template.json",
"cluster.get_component_template.json",
"cluster.put_component_template.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ public bool? Verbose
}

///<summary>Request options for Transforms <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
public class TransformsRequestParameters : RequestParameters<TransformsRequestParameters>
public class CatTransformsRequestParameters : RequestParameters<CatTransformsRequestParameters>
{
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
///<summary>Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)</summary>
Expand Down
8 changes: 4 additions & 4 deletions src/Elasticsearch.Net/ElasticLowLevelClient.Cat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,23 +432,23 @@ public Task<TResponse> ThreadPoolAsync<TResponse>(string threadPoolPatterns, Cat
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_cat/thread_pool/{threadPoolPatterns:threadPoolPatterns}"), ctx, null, RequestParams(requestParameters));
///<summary>GET on /_cat/transforms <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
public TResponse Transforms<TResponse>(TransformsRequestParameters requestParameters = null)
public TResponse Transforms<TResponse>(CatTransformsRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(GET, "_cat/transforms", null, RequestParams(requestParameters));
///<summary>GET on /_cat/transforms <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
[MapsApi("cat.transforms", "")]
public Task<TResponse> TransformsAsync<TResponse>(TransformsRequestParameters requestParameters = null, CancellationToken ctx = default)
public Task<TResponse> TransformsAsync<TResponse>(CatTransformsRequestParameters requestParameters = null, CancellationToken ctx = default)
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, "_cat/transforms", ctx, null, RequestParams(requestParameters));
///<summary>GET on /_cat/transforms/{transform_id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
///<param name = "transformId">The id of the transform for which to get stats. &#x27;_all&#x27; or &#x27;*&#x27; implies all transforms</param>
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
public TResponse Transforms<TResponse>(string transformId, TransformsRequestParameters requestParameters = null)
public TResponse Transforms<TResponse>(string transformId, CatTransformsRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(GET, Url($"_cat/transforms/{transformId:transformId}"), null, RequestParams(requestParameters));
///<summary>GET on /_cat/transforms/{transform_id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
///<param name = "transformId">The id of the transform for which to get stats. &#x27;_all&#x27; or &#x27;*&#x27; implies all transforms</param>
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
[MapsApi("cat.transforms", "transform_id")]
public Task<TResponse> TransformsAsync<TResponse>(string transformId, TransformsRequestParameters requestParameters = null, CancellationToken ctx = default)
public Task<TResponse> TransformsAsync<TResponse>(string transformId, CatTransformsRequestParameters requestParameters = null, CancellationToken ctx = default)
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_cat/transforms/{transformId:transformId}"), ctx, null, RequestParams(requestParameters));
}
}
179 changes: 179 additions & 0 deletions src/Nest/Cat/CatTransforms/CatTransformsRecord.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
using System;
using System.Runtime.Serialization;
using Elasticsearch.Net.Utf8Json;

namespace Nest
{
[DataContract]
public class CatTransformsRecord : ICatRecord
{
/// <summary>
/// The timestamp when changes were last detected in the source indices.
/// </summary>
[DataMember(Name ="changes_last_detection_time")]
public string ChangesLastDetectionTime { get; internal set; }

/// <summary>
/// Exponential moving average of the duration of the checkpoint, in milliseconds.
/// </summary>
[DataMember(Name ="checkpoint_duration_time_exp_avg")]
public long? CheckpointDurationTimeExpAvg { get; internal set; }

/// <summary>
/// (Default) The time the transform was created.
/// </summary>
[DataMember(Name ="create_time")]
public DateTimeOffset CreateTime { get; internal set; }

/// <summary>
/// (Default) The description of the transform.
/// </summary>
[DataMember(Name ="description")]
public string Description { get; internal set; }

/// <summary>
/// (Default) The destination index for the transform.
/// </summary>
[DataMember(Name ="dest_index")]
public string DestinationIndex { get; internal set; }

/// <summary>
/// The number of documents that have been indexed into the destination index for the transform.
/// </summary>
[DataMember(Name ="documents_indexed")]
public long? DocumentsIndexed { get; internal set; }

/// <summary>
/// The number of documents that have been processed from the source index of the transform.
/// </summary>
[DataMember(Name ="documents_processed")]
public long? DocumentsProcessed { get; internal set; }

/// <summary>
/// (Default) The interval between checks for changes in the source indices when the transform is running continuously. Also determines the
/// retry interval in the event of transient failures while the transform is searching or indexing. The minimum value is 1s and the maximum
/// is 1h. The default value is 1m.
/// </summary>
[DataMember(Name ="frequency")]
public Time Frequency { get; internal set; }

/// <summary>
/// (Default) Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and
/// underscores. It must start and end with alphanumeric characters.
/// </summary>
[DataMember(Name ="id")]
public string Id { get; internal set; }

/// <summary>
/// The number of indexing failures.
/// </summary>
[DataMember(Name ="index_failure")]
public long? IndexFailure { get; internal set; }

/// <summary>
/// The amount of time spent indexing, in milliseconds.
/// </summary>
[DataMember(Name ="index_time")]
public long? IndexTime { get; internal set; }

/// <summary>
/// The number of indices created.
/// </summary>
[DataMember(Name ="index_total")]
public long? IndexTotal { get; internal set; }

/// <summary>
/// Exponential moving average of the number of new documents that have been indexed.
/// </summary>
[DataMember(Name ="indexed_documents_exp_avg")]
public long? IndexedDocumentsExpAvg { get; internal set; }

/// <summary>
/// (Default) Defines the initial page size to use for the composite aggregation for each checkpoint. If circuit breaker exceptions occur,
/// the page size is dynamically adjusted to a lower value. The minimum value is 10 and the maximum is 10,000. The default value is 500.
/// </summary>
[DataMember(Name ="max_page_search_size")]
public long? MaxPageSearchSize { get; internal set; }

/// <summary>
/// The number of search or bulk index operations processed. Documents are processed in batches instead of individually.
/// </summary>
[DataMember(Name ="pages_processed")]
public long? PagesProcessed { get; internal set; }

/// <summary>
/// (Default) The unique identifier for a pipeline.
/// </summary>
[DataMember(Name ="pipeline")]
public string Pipeline { get; internal set; }

/// <summary>
/// Exponential moving average of the number of documents that have been processed.
/// </summary>
[DataMember(Name ="processed_documents_exp_avg")]
public long? ProcessedDocumentsExpAvg { get; internal set; }

/// <summary>
/// The amount of time spent processing results, in milliseconds.
/// </summary>
[DataMember(Name ="processing_time")]
public long? ProcessingTime { get; internal set; }

/// <summary>
/// If a transform has a failed state, this property provides details about the reason for the failure.
/// </summary>
[DataMember(Name ="reason")]
public string Reason { get; internal set; }

/// <summary>
/// The number of search failures.
/// </summary>
[DataMember(Name ="search_failure")]
public long? SearchFailure { get; internal set; }

/// <summary>
/// The amount of time spent searching, in milliseconds.
/// </summary>
[DataMember(Name ="search_time")]
public long? SearchTime { get; internal set; }

/// <summary>
/// The number of search operations on the source index for the transform.
/// </summary>
[DataMember(Name ="search_total")]
public long? SearchTotal { get; internal set; }

/// <summary>
/// (Default) The source indices for the transform. It can be a single index, an index pattern (for example, "myindex*"), an array of indices
/// (for example, ["index1", "index2"]), or an array of index patterns (for example, ["myindex1-*", "myindex2-*"].
/// </summary>
[DataMember(Name ="source_index")]
[JsonFormatter(typeof(IndicesFormatter))]
public Indices SourceIndices { get; internal set; }

/// <summary>
/// (Default) The status of the transform.
/// </summary>
[DataMember(Name ="state")]
public TransformState State { get; internal set; }

/// <summary>
/// (Default) Indicates the type of transform.
/// </summary>
[DataMember(Name ="transform_type")]
public TransformType TransformType { get; internal set; }

/// <summary>
/// The number of times the transform has been triggered by the scheduler. For example, the scheduler triggers the transform indexer to
/// check for updates or ingest new data at an interval specified in the frequency property.
/// </summary>
[DataMember(Name ="trigger_count")]
public long? TriggerCount { get; internal set; }

/// <summary>
/// (Default) The version of Elasticsearch that existed on the node when the transform was created.
/// </summary>
[DataMember(Name ="version")]
public string Version { get; internal set; }
}
}
9 changes: 9 additions & 0 deletions src/Nest/Cat/CatTransforms/CatTransformsRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Nest
{
[MapsApi("cat.transforms.json")]
public partial interface ICatTransformsRequest { }

public partial class CatTransformsRequest { }

public partial class CatTransformsDescriptor { }
}
16 changes: 16 additions & 0 deletions src/Nest/Cat/CatTransforms/TransformState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Runtime.Serialization;
using Elasticsearch.Net;

namespace Nest
{
[StringEnum]
public enum TransformState
{
[EnumMember(Value = "STARTED")] Started,
[EnumMember(Value = "INDEXING")] Indexing,
[EnumMember(Value = "ABORTING")] Aborting,
[EnumMember(Value = "STOPPING")] Stopping,
[EnumMember(Value = "STOPPED")] Stopped,
[EnumMember(Value = "FAILED")] Failed
}
}
15 changes: 15 additions & 0 deletions src/Nest/Cat/CatTransforms/TransformType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Runtime.Serialization;
using Elasticsearch.Net;

namespace Nest
{
[StringEnum]
public enum TransformType
{
[EnumMember(Value = "batch")]
Batch,

[EnumMember(Value = "continuous")]
Continuous
}
}
38 changes: 38 additions & 0 deletions src/Nest/Descriptors.Cat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,42 @@ public CatThreadPoolDescriptor(Names threadPoolPatterns): base(r => r.Optional("
///<summary>Verbose mode. Display column headers</summary>
public CatThreadPoolDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
}

///<summary>Descriptor for Transforms <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
public partial class CatTransformsDescriptor : RequestDescriptorBase<CatTransformsDescriptor, CatTransformsRequestParameters, ICatTransformsRequest>, ICatTransformsRequest
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.CatTransforms;
///<summary>/_cat/transforms</summary>
public CatTransformsDescriptor(): base()
{
}

///<summary>/_cat/transforms/{transform_id}</summary>
///<param name = "transformId">Optional, accepts null</param>
public CatTransformsDescriptor(Id transformId): base(r => r.Optional("transform_id", transformId))
{
}

// values part of the url path
Id ICatTransformsRequest.TransformId => Self.RouteValues.Get<Id>("transform_id");
///<summary>The id of the transform for which to get stats. '_all' or '*' implies all transforms</summary>
public CatTransformsDescriptor TransformId(Id transformId) => Assign(transformId, (a, v) => a.RouteValues.Optional("transform_id", v));
// Request parameters
///<summary>Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)</summary>
public CatTransformsDescriptor AllowNoMatch(bool? allownomatch = true) => Qs("allow_no_match", allownomatch);
///<summary>a short version of the Accept header, e.g. json, yaml</summary>
public CatTransformsDescriptor Format(string format) => Qs("format", format);
///<summary>skips a number of transform configs, defaults to 0</summary>
public CatTransformsDescriptor From(int? from) => Qs("from", from);
///<summary>Comma-separated list of column names to display</summary>
public CatTransformsDescriptor Headers(params string[] headers) => Qs("h", headers);
///<summary>Return help information</summary>
public CatTransformsDescriptor Help(bool? help = true) => Qs("help", help);
///<summary>specifies a max number of transforms to get, defaults to 100</summary>
public CatTransformsDescriptor Size(int? size) => Qs("size", size);
///<summary>Comma-separated list of column names or column aliases to sort by</summary>
public CatTransformsDescriptor SortByColumns(params string[] sortbycolumns) => Qs("s", sortbycolumns);
///<summary>Verbose mode. Display column headers</summary>
public CatTransformsDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
}
}
24 changes: 24 additions & 0 deletions src/Nest/ElasticClient.Cat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,5 +516,29 @@ internal CatNamespace(ElasticClient client): base(client)
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html</a>
/// </summary>
public Task<CatResponse<CatThreadPoolRecord>> ThreadPoolAsync(ICatThreadPoolRequest request, CancellationToken ct = default) => DoCatAsync<ICatThreadPoolRequest, CatThreadPoolRequestParameters, CatThreadPoolRecord>(request, ct);
/// <summary>
/// <c>GET</c> request to the <c>cat.transforms</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</a>
/// </summary>
public CatResponse<CatTransformsRecord> Transforms(Func<CatTransformsDescriptor, ICatTransformsRequest> selector = null) => Transforms(selector.InvokeOrDefault(new CatTransformsDescriptor()));
/// <summary>
/// <c>GET</c> request to the <c>cat.transforms</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</a>
/// </summary>
public Task<CatResponse<CatTransformsRecord>> TransformsAsync(Func<CatTransformsDescriptor, ICatTransformsRequest> selector = null, CancellationToken ct = default) => TransformsAsync(selector.InvokeOrDefault(new CatTransformsDescriptor()), ct);
/// <summary>
/// <c>GET</c> request to the <c>cat.transforms</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</a>
/// </summary>
public CatResponse<CatTransformsRecord> Transforms(ICatTransformsRequest request) => DoCat<ICatTransformsRequest, CatTransformsRequestParameters, CatTransformsRecord>(request);
/// <summary>
/// <c>GET</c> request to the <c>cat.transforms</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</a>
/// </summary>
public Task<CatResponse<CatTransformsRecord>> TransformsAsync(ICatTransformsRequest request, CancellationToken ct = default) => DoCatAsync<ICatTransformsRequest, CatTransformsRequestParameters, CatTransformsRecord>(request, ct);
}
}
Loading