Skip to content

Commit 296dc75

Browse files
codebraingithub-actions[bot]
authored andcommitted
Implement cat.transforms (#4557)
Implement cat.transforms
1 parent af7b51c commit 296dc75

File tree

12 files changed

+462
-6
lines changed

12 files changed

+462
-6
lines changed

src/ApiGenerator/Configuration/CodeConfiguration.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public static class CodeConfiguration
6262
"cat.ml_datafeeds.json",
6363
"cat.ml_jobs.json",
6464
"cat.ml_trained_models.json",
65-
"cat.transforms.json",
6665
"cluster.delete_component_template.json",
6766
"cluster.get_component_template.json",
6867
"cluster.put_component_template.json",

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Cat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ public bool? Verbose
15261526
}
15271527

15281528
///<summary>Request options for Transforms <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
1529-
public class TransformsRequestParameters : RequestParameters<TransformsRequestParameters>
1529+
public class CatTransformsRequestParameters : RequestParameters<CatTransformsRequestParameters>
15301530
{
15311531
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
15321532
///<summary>Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)</summary>

src/Elasticsearch.Net/ElasticLowLevelClient.Cat.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,23 +432,23 @@ public Task<TResponse> ThreadPoolAsync<TResponse>(string threadPoolPatterns, Cat
432432
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_cat/thread_pool/{threadPoolPatterns:threadPoolPatterns}"), ctx, null, RequestParams(requestParameters));
433433
///<summary>GET on /_cat/transforms <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
434434
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
435-
public TResponse Transforms<TResponse>(TransformsRequestParameters requestParameters = null)
435+
public TResponse Transforms<TResponse>(CatTransformsRequestParameters requestParameters = null)
436436
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(GET, "_cat/transforms", null, RequestParams(requestParameters));
437437
///<summary>GET on /_cat/transforms <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
438438
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
439439
[MapsApi("cat.transforms", "")]
440-
public Task<TResponse> TransformsAsync<TResponse>(TransformsRequestParameters requestParameters = null, CancellationToken ctx = default)
440+
public Task<TResponse> TransformsAsync<TResponse>(CatTransformsRequestParameters requestParameters = null, CancellationToken ctx = default)
441441
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, "_cat/transforms", ctx, null, RequestParams(requestParameters));
442442
///<summary>GET on /_cat/transforms/{transform_id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
443443
///<param name = "transformId">The id of the transform for which to get stats. &#x27;_all&#x27; or &#x27;*&#x27; implies all transforms</param>
444444
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
445-
public TResponse Transforms<TResponse>(string transformId, TransformsRequestParameters requestParameters = null)
445+
public TResponse Transforms<TResponse>(string transformId, CatTransformsRequestParameters requestParameters = null)
446446
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(GET, Url($"_cat/transforms/{transformId:transformId}"), null, RequestParams(requestParameters));
447447
///<summary>GET on /_cat/transforms/{transform_id} <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
448448
///<param name = "transformId">The id of the transform for which to get stats. &#x27;_all&#x27; or &#x27;*&#x27; implies all transforms</param>
449449
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
450450
[MapsApi("cat.transforms", "transform_id")]
451-
public Task<TResponse> TransformsAsync<TResponse>(string transformId, TransformsRequestParameters requestParameters = null, CancellationToken ctx = default)
451+
public Task<TResponse> TransformsAsync<TResponse>(string transformId, CatTransformsRequestParameters requestParameters = null, CancellationToken ctx = default)
452452
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_cat/transforms/{transformId:transformId}"), ctx, null, RequestParams(requestParameters));
453453
}
454454
}
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
using Elasticsearch.Net.Utf8Json;
4+
5+
namespace Nest
6+
{
7+
[DataContract]
8+
public class CatTransformsRecord : ICatRecord
9+
{
10+
/// <summary>
11+
/// The timestamp when changes were last detected in the source indices.
12+
/// </summary>
13+
[DataMember(Name ="changes_last_detection_time")]
14+
public string ChangesLastDetectionTime { get; internal set; }
15+
16+
/// <summary>
17+
/// Exponential moving average of the duration of the checkpoint, in milliseconds.
18+
/// </summary>
19+
[DataMember(Name ="checkpoint_duration_time_exp_avg")]
20+
public long? CheckpointDurationTimeExpAvg { get; internal set; }
21+
22+
/// <summary>
23+
/// (Default) The time the transform was created.
24+
/// </summary>
25+
[DataMember(Name ="create_time")]
26+
public DateTimeOffset CreateTime { get; internal set; }
27+
28+
/// <summary>
29+
/// (Default) The description of the transform.
30+
/// </summary>
31+
[DataMember(Name ="description")]
32+
public string Description { get; internal set; }
33+
34+
/// <summary>
35+
/// (Default) The destination index for the transform.
36+
/// </summary>
37+
[DataMember(Name ="dest_index")]
38+
public string DestinationIndex { get; internal set; }
39+
40+
/// <summary>
41+
/// The number of documents that have been indexed into the destination index for the transform.
42+
/// </summary>
43+
[DataMember(Name ="documents_indexed")]
44+
public long? DocumentsIndexed { get; internal set; }
45+
46+
/// <summary>
47+
/// The number of documents that have been processed from the source index of the transform.
48+
/// </summary>
49+
[DataMember(Name ="documents_processed")]
50+
public long? DocumentsProcessed { get; internal set; }
51+
52+
/// <summary>
53+
/// (Default) The interval between checks for changes in the source indices when the transform is running continuously. Also determines the
54+
/// retry interval in the event of transient failures while the transform is searching or indexing. The minimum value is 1s and the maximum
55+
/// is 1h. The default value is 1m.
56+
/// </summary>
57+
[DataMember(Name ="frequency")]
58+
public Time Frequency { get; internal set; }
59+
60+
/// <summary>
61+
/// (Default) Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and
62+
/// underscores. It must start and end with alphanumeric characters.
63+
/// </summary>
64+
[DataMember(Name ="id")]
65+
public string Id { get; internal set; }
66+
67+
/// <summary>
68+
/// The number of indexing failures.
69+
/// </summary>
70+
[DataMember(Name ="index_failure")]
71+
public long? IndexFailure { get; internal set; }
72+
73+
/// <summary>
74+
/// The amount of time spent indexing, in milliseconds.
75+
/// </summary>
76+
[DataMember(Name ="index_time")]
77+
public long? IndexTime { get; internal set; }
78+
79+
/// <summary>
80+
/// The number of indices created.
81+
/// </summary>
82+
[DataMember(Name ="index_total")]
83+
public long? IndexTotal { get; internal set; }
84+
85+
/// <summary>
86+
/// Exponential moving average of the number of new documents that have been indexed.
87+
/// </summary>
88+
[DataMember(Name ="indexed_documents_exp_avg")]
89+
public long? IndexedDocumentsExpAvg { get; internal set; }
90+
91+
/// <summary>
92+
/// (Default) Defines the initial page size to use for the composite aggregation for each checkpoint. If circuit breaker exceptions occur,
93+
/// 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.
94+
/// </summary>
95+
[DataMember(Name ="max_page_search_size")]
96+
public long? MaxPageSearchSize { get; internal set; }
97+
98+
/// <summary>
99+
/// The number of search or bulk index operations processed. Documents are processed in batches instead of individually.
100+
/// </summary>
101+
[DataMember(Name ="pages_processed")]
102+
public long? PagesProcessed { get; internal set; }
103+
104+
/// <summary>
105+
/// (Default) The unique identifier for a pipeline.
106+
/// </summary>
107+
[DataMember(Name ="pipeline")]
108+
public string Pipeline { get; internal set; }
109+
110+
/// <summary>
111+
/// Exponential moving average of the number of documents that have been processed.
112+
/// </summary>
113+
[DataMember(Name ="processed_documents_exp_avg")]
114+
public long? ProcessedDocumentsExpAvg { get; internal set; }
115+
116+
/// <summary>
117+
/// The amount of time spent processing results, in milliseconds.
118+
/// </summary>
119+
[DataMember(Name ="processing_time")]
120+
public long? ProcessingTime { get; internal set; }
121+
122+
/// <summary>
123+
/// If a transform has a failed state, this property provides details about the reason for the failure.
124+
/// </summary>
125+
[DataMember(Name ="reason")]
126+
public string Reason { get; internal set; }
127+
128+
/// <summary>
129+
/// The number of search failures.
130+
/// </summary>
131+
[DataMember(Name ="search_failure")]
132+
public long? SearchFailure { get; internal set; }
133+
134+
/// <summary>
135+
/// The amount of time spent searching, in milliseconds.
136+
/// </summary>
137+
[DataMember(Name ="search_time")]
138+
public long? SearchTime { get; internal set; }
139+
140+
/// <summary>
141+
/// The number of search operations on the source index for the transform.
142+
/// </summary>
143+
[DataMember(Name ="search_total")]
144+
public long? SearchTotal { get; internal set; }
145+
146+
/// <summary>
147+
/// (Default) The source indices for the transform. It can be a single index, an index pattern (for example, "myindex*"), an array of indices
148+
/// (for example, ["index1", "index2"]), or an array of index patterns (for example, ["myindex1-*", "myindex2-*"].
149+
/// </summary>
150+
[DataMember(Name ="source_index")]
151+
[JsonFormatter(typeof(IndicesFormatter))]
152+
public Indices SourceIndices { get; internal set; }
153+
154+
/// <summary>
155+
/// (Default) The status of the transform.
156+
/// </summary>
157+
[DataMember(Name ="state")]
158+
public TransformState State { get; internal set; }
159+
160+
/// <summary>
161+
/// (Default) Indicates the type of transform.
162+
/// </summary>
163+
[DataMember(Name ="transform_type")]
164+
public TransformType TransformType { get; internal set; }
165+
166+
/// <summary>
167+
/// The number of times the transform has been triggered by the scheduler. For example, the scheduler triggers the transform indexer to
168+
/// check for updates or ingest new data at an interval specified in the frequency property.
169+
/// </summary>
170+
[DataMember(Name ="trigger_count")]
171+
public long? TriggerCount { get; internal set; }
172+
173+
/// <summary>
174+
/// (Default) The version of Elasticsearch that existed on the node when the transform was created.
175+
/// </summary>
176+
[DataMember(Name ="version")]
177+
public string Version { get; internal set; }
178+
}
179+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Nest
2+
{
3+
[MapsApi("cat.transforms.json")]
4+
public partial interface ICatTransformsRequest { }
5+
6+
public partial class CatTransformsRequest { }
7+
8+
public partial class CatTransformsDescriptor { }
9+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Runtime.Serialization;
2+
using Elasticsearch.Net;
3+
4+
namespace Nest
5+
{
6+
[StringEnum]
7+
public enum TransformState
8+
{
9+
[EnumMember(Value = "STARTED")] Started,
10+
[EnumMember(Value = "INDEXING")] Indexing,
11+
[EnumMember(Value = "ABORTING")] Aborting,
12+
[EnumMember(Value = "STOPPING")] Stopping,
13+
[EnumMember(Value = "STOPPED")] Stopped,
14+
[EnumMember(Value = "FAILED")] Failed
15+
}
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Runtime.Serialization;
2+
using Elasticsearch.Net;
3+
4+
namespace Nest
5+
{
6+
[StringEnum]
7+
public enum TransformType
8+
{
9+
[EnumMember(Value = "batch")]
10+
Batch,
11+
12+
[EnumMember(Value = "continuous")]
13+
Continuous
14+
}
15+
}

src/Nest/Descriptors.Cat.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,4 +672,42 @@ public CatThreadPoolDescriptor(Names threadPoolPatterns): base(r => r.Optional("
672672
///<summary>Verbose mode. Display column headers</summary>
673673
public CatThreadPoolDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
674674
}
675+
676+
///<summary>Descriptor for Transforms <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html</para></summary>
677+
public partial class CatTransformsDescriptor : RequestDescriptorBase<CatTransformsDescriptor, CatTransformsRequestParameters, ICatTransformsRequest>, ICatTransformsRequest
678+
{
679+
internal override ApiUrls ApiUrls => ApiUrlsLookups.CatTransforms;
680+
///<summary>/_cat/transforms</summary>
681+
public CatTransformsDescriptor(): base()
682+
{
683+
}
684+
685+
///<summary>/_cat/transforms/{transform_id}</summary>
686+
///<param name = "transformId">Optional, accepts null</param>
687+
public CatTransformsDescriptor(Id transformId): base(r => r.Optional("transform_id", transformId))
688+
{
689+
}
690+
691+
// values part of the url path
692+
Id ICatTransformsRequest.TransformId => Self.RouteValues.Get<Id>("transform_id");
693+
///<summary>The id of the transform for which to get stats. '_all' or '*' implies all transforms</summary>
694+
public CatTransformsDescriptor TransformId(Id transformId) => Assign(transformId, (a, v) => a.RouteValues.Optional("transform_id", v));
695+
// Request parameters
696+
///<summary>Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)</summary>
697+
public CatTransformsDescriptor AllowNoMatch(bool? allownomatch = true) => Qs("allow_no_match", allownomatch);
698+
///<summary>a short version of the Accept header, e.g. json, yaml</summary>
699+
public CatTransformsDescriptor Format(string format) => Qs("format", format);
700+
///<summary>skips a number of transform configs, defaults to 0</summary>
701+
public CatTransformsDescriptor From(int? from) => Qs("from", from);
702+
///<summary>Comma-separated list of column names to display</summary>
703+
public CatTransformsDescriptor Headers(params string[] headers) => Qs("h", headers);
704+
///<summary>Return help information</summary>
705+
public CatTransformsDescriptor Help(bool? help = true) => Qs("help", help);
706+
///<summary>specifies a max number of transforms to get, defaults to 100</summary>
707+
public CatTransformsDescriptor Size(int? size) => Qs("size", size);
708+
///<summary>Comma-separated list of column names or column aliases to sort by</summary>
709+
public CatTransformsDescriptor SortByColumns(params string[] sortbycolumns) => Qs("s", sortbycolumns);
710+
///<summary>Verbose mode. Display column headers</summary>
711+
public CatTransformsDescriptor Verbose(bool? verbose = true) => Qs("v", verbose);
712+
}
675713
}

src/Nest/ElasticClient.Cat.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,5 +516,29 @@ internal CatNamespace(ElasticClient client): base(client)
516516
/// <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>
517517
/// </summary>
518518
public Task<CatResponse<CatThreadPoolRecord>> ThreadPoolAsync(ICatThreadPoolRequest request, CancellationToken ct = default) => DoCatAsync<ICatThreadPoolRequest, CatThreadPoolRequestParameters, CatThreadPoolRecord>(request, ct);
519+
/// <summary>
520+
/// <c>GET</c> request to the <c>cat.transforms</c> API, read more about this API online:
521+
/// <para></para>
522+
/// <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>
523+
/// </summary>
524+
public CatResponse<CatTransformsRecord> Transforms(Func<CatTransformsDescriptor, ICatTransformsRequest> selector = null) => Transforms(selector.InvokeOrDefault(new CatTransformsDescriptor()));
525+
/// <summary>
526+
/// <c>GET</c> request to the <c>cat.transforms</c> API, read more about this API online:
527+
/// <para></para>
528+
/// <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>
529+
/// </summary>
530+
public Task<CatResponse<CatTransformsRecord>> TransformsAsync(Func<CatTransformsDescriptor, ICatTransformsRequest> selector = null, CancellationToken ct = default) => TransformsAsync(selector.InvokeOrDefault(new CatTransformsDescriptor()), ct);
531+
/// <summary>
532+
/// <c>GET</c> request to the <c>cat.transforms</c> API, read more about this API online:
533+
/// <para></para>
534+
/// <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>
535+
/// </summary>
536+
public CatResponse<CatTransformsRecord> Transforms(ICatTransformsRequest request) => DoCat<ICatTransformsRequest, CatTransformsRequestParameters, CatTransformsRecord>(request);
537+
/// <summary>
538+
/// <c>GET</c> request to the <c>cat.transforms</c> API, read more about this API online:
539+
/// <para></para>
540+
/// <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>
541+
/// </summary>
542+
public Task<CatResponse<CatTransformsRecord>> TransformsAsync(ICatTransformsRequest request, CancellationToken ct = default) => DoCatAsync<ICatTransformsRequest, CatTransformsRequestParameters, CatTransformsRecord>(request, ct);
519543
}
520544
}

0 commit comments

Comments
 (0)