Skip to content

Commit

Permalink
Add data streams APIs
Browse files Browse the repository at this point in the history
This commit adds support for the data streams APIs
to the high level client.

(cherry picked from commit 5b84abe)
  • Loading branch information
russcam committed Aug 6, 2020
1 parent b8dfa99 commit 1645715
Show file tree
Hide file tree
Showing 18 changed files with 870 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ public static class CodeConfiguration
"get_script_languages.json", // 7.7 experimental

"indices.exist_type.json", // already removed on client
"indices.create_data_stream.json", // 7.7 experimental
"indices.delete_data_stream.json", // 7.7 experimental
"indices.get_data_stream.json", // 7.7 experimental
"indices.get_data_streams.json", // 7.7 experimental
"indices.data_streams_stats.json", // 7.7 experimental

"ml.delete_trained_model.json", // 7.7 experimental
"ml.evaluate_data_frame.json", // 7.7 experimental
Expand Down
86 changes: 86 additions & 0 deletions src/Nest/Descriptors.Indices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,49 @@ public CreateIndexDescriptor Index<TOther>()
public CreateIndexDescriptor WaitForActiveShards(string waitforactiveshards) => Qs("wait_for_active_shards", waitforactiveshards);
}

///<summary>Descriptor for CreateDataStream <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</para></summary>
public partial class CreateDataStreamDescriptor : RequestDescriptorBase<CreateDataStreamDescriptor, CreateDataStreamRequestParameters, ICreateDataStreamRequest>, ICreateDataStreamRequest
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesCreateDataStream;
///<summary>/_data_stream/{name}</summary>
///<param name = "name">this parameter is required</param>
public CreateDataStreamDescriptor(Name name): base(r => r.Required("name", name))
{
}

///<summary>Used for serialization purposes, making sure we have a parameterless constructor</summary>
[SerializationConstructor]
protected CreateDataStreamDescriptor(): base()
{
}

// values part of the url path
Name ICreateDataStreamRequest.Name => Self.RouteValues.Get<Name>("name");
// Request parameters
}

///<summary>Descriptor for DataStreamsStats <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</para></summary>
public partial class DataStreamsStatsDescriptor : RequestDescriptorBase<DataStreamsStatsDescriptor, DataStreamsStatsRequestParameters, IDataStreamsStatsRequest>, IDataStreamsStatsRequest
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesDataStreamsStats;
///<summary>/_data_stream/_stats</summary>
public DataStreamsStatsDescriptor(): base()
{
}

///<summary>/_data_stream/{name}/_stats</summary>
///<param name = "name">Optional, accepts null</param>
public DataStreamsStatsDescriptor(Names name): base(r => r.Optional("name", name))
{
}

// values part of the url path
Names IDataStreamsStatsRequest.Name => Self.RouteValues.Get<Names>("name");
///<summary>A comma-separated list of data stream names; use the special string `_all` or Indices.All to perform the operation on all data streams</summary>
public DataStreamsStatsDescriptor Name(Names name) => Assign(name, (a, v) => a.RouteValues.Optional("name", v));
// Request parameters
}

///<summary>Descriptor for Delete <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html</para></summary>
public partial class DeleteIndexDescriptor : RequestDescriptorBase<DeleteIndexDescriptor, DeleteIndexRequestParameters, IDeleteIndexRequest>, IDeleteIndexRequest
{
Expand Down Expand Up @@ -319,6 +362,27 @@ public DeleteAliasDescriptor Index<TOther>()
public DeleteAliasDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
}

///<summary>Descriptor for DeleteDataStream <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</para></summary>
public partial class DeleteDataStreamDescriptor : RequestDescriptorBase<DeleteDataStreamDescriptor, DeleteDataStreamRequestParameters, IDeleteDataStreamRequest>, IDeleteDataStreamRequest
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesDeleteDataStream;
///<summary>/_data_stream/{name}</summary>
///<param name = "name">this parameter is required</param>
public DeleteDataStreamDescriptor(Names name): base(r => r.Required("name", name))
{
}

///<summary>Used for serialization purposes, making sure we have a parameterless constructor</summary>
[SerializationConstructor]
protected DeleteDataStreamDescriptor(): base()
{
}

// values part of the url path
Names IDeleteDataStreamRequest.Name => Self.RouteValues.Get<Names>("name");
// Request parameters
}

///<summary>Descriptor for DeleteTemplate <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html</para></summary>
public partial class DeleteIndexTemplateDescriptor : RequestDescriptorBase<DeleteIndexTemplateDescriptor, DeleteIndexTemplateRequestParameters, IDeleteIndexTemplateRequest>, IDeleteIndexTemplateRequest
{
Expand Down Expand Up @@ -735,6 +799,28 @@ public GetAliasDescriptor Index<TOther>()
public GetAliasDescriptor Local(bool? local = true) => Qs("local", local);
}

///<summary>Descriptor for GetDataStream <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</para></summary>
public partial class GetDataStreamDescriptor : RequestDescriptorBase<GetDataStreamDescriptor, GetDataStreamRequestParameters, IGetDataStreamRequest>, IGetDataStreamRequest
{
internal override ApiUrls ApiUrls => ApiUrlsLookups.IndicesGetDataStream;
///<summary>/_data_stream</summary>
public GetDataStreamDescriptor(): base()
{
}

///<summary>/_data_stream/{name}</summary>
///<param name = "name">Optional, accepts null</param>
public GetDataStreamDescriptor(Names name): base(r => r.Optional("name", name))
{
}

// values part of the url path
Names IGetDataStreamRequest.Name => Self.RouteValues.Get<Names>("name");
///<summary>A comma-separated list of data streams to get; use `*` to get all data streams</summary>
public GetDataStreamDescriptor Name(Names name) => Assign(name, (a, v) => a.RouteValues.Optional("name", v));
// Request parameters
}

///<summary>Descriptor for GetFieldMapping <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html</para></summary>
public partial class GetFieldMappingDescriptor<TDocument> : RequestDescriptorBase<GetFieldMappingDescriptor<TDocument>, GetFieldMappingRequestParameters, IGetFieldMappingRequest>, IGetFieldMappingRequest
{
Expand Down
96 changes: 96 additions & 0 deletions src/Nest/ElasticClient.Indices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,54 @@ internal IndicesNamespace(ElasticClient client): base(client)
/// </summary>
public Task<CreateIndexResponse> CreateAsync(ICreateIndexRequest request, CancellationToken ct = default) => DoRequestAsync<ICreateIndexRequest, CreateIndexResponse>(request, request.RequestParameters, ct);
/// <summary>
/// <c>PUT</c> request to the <c>indices.create_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public CreateDataStreamResponse CreateDataStream(Name name, Func<CreateDataStreamDescriptor, ICreateDataStreamRequest> selector = null) => CreateDataStream(selector.InvokeOrDefault(new CreateDataStreamDescriptor(name: name)));
/// <summary>
/// <c>PUT</c> request to the <c>indices.create_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public Task<CreateDataStreamResponse> CreateDataStreamAsync(Name name, Func<CreateDataStreamDescriptor, ICreateDataStreamRequest> selector = null, CancellationToken ct = default) => CreateDataStreamAsync(selector.InvokeOrDefault(new CreateDataStreamDescriptor(name: name)), ct);
/// <summary>
/// <c>PUT</c> request to the <c>indices.create_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public CreateDataStreamResponse CreateDataStream(ICreateDataStreamRequest request) => DoRequest<ICreateDataStreamRequest, CreateDataStreamResponse>(request, request.RequestParameters);
/// <summary>
/// <c>PUT</c> request to the <c>indices.create_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public Task<CreateDataStreamResponse> CreateDataStreamAsync(ICreateDataStreamRequest request, CancellationToken ct = default) => DoRequestAsync<ICreateDataStreamRequest, CreateDataStreamResponse>(request, request.RequestParameters, ct);
/// <summary>
/// <c>GET</c> request to the <c>indices.data_streams_stats</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public DataStreamsStatsResponse DataStreamsStats(Names name = null, Func<DataStreamsStatsDescriptor, IDataStreamsStatsRequest> selector = null) => DataStreamsStats(selector.InvokeOrDefault(new DataStreamsStatsDescriptor().Name(name: name)));
/// <summary>
/// <c>GET</c> request to the <c>indices.data_streams_stats</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public Task<DataStreamsStatsResponse> DataStreamsStatsAsync(Names name = null, Func<DataStreamsStatsDescriptor, IDataStreamsStatsRequest> selector = null, CancellationToken ct = default) => DataStreamsStatsAsync(selector.InvokeOrDefault(new DataStreamsStatsDescriptor().Name(name: name)), ct);
/// <summary>
/// <c>GET</c> request to the <c>indices.data_streams_stats</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public DataStreamsStatsResponse DataStreamsStats(IDataStreamsStatsRequest request) => DoRequest<IDataStreamsStatsRequest, DataStreamsStatsResponse>(request, request.RequestParameters);
/// <summary>
/// <c>GET</c> request to the <c>indices.data_streams_stats</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public Task<DataStreamsStatsResponse> DataStreamsStatsAsync(IDataStreamsStatsRequest request, CancellationToken ct = default) => DoRequestAsync<IDataStreamsStatsRequest, DataStreamsStatsResponse>(request, request.RequestParameters, ct);
/// <summary>
/// <c>DELETE</c> request to the <c>indices.delete</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html</a>
Expand Down Expand Up @@ -229,6 +277,30 @@ internal IndicesNamespace(ElasticClient client): base(client)
/// </summary>
public Task<DeleteAliasResponse> DeleteAliasAsync(IDeleteAliasRequest request, CancellationToken ct = default) => DoRequestAsync<IDeleteAliasRequest, DeleteAliasResponse>(request, request.RequestParameters, ct);
/// <summary>
/// <c>DELETE</c> request to the <c>indices.delete_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public DeleteDataStreamResponse DeleteDataStream(Names name, Func<DeleteDataStreamDescriptor, IDeleteDataStreamRequest> selector = null) => DeleteDataStream(selector.InvokeOrDefault(new DeleteDataStreamDescriptor(name: name)));
/// <summary>
/// <c>DELETE</c> request to the <c>indices.delete_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public Task<DeleteDataStreamResponse> DeleteDataStreamAsync(Names name, Func<DeleteDataStreamDescriptor, IDeleteDataStreamRequest> selector = null, CancellationToken ct = default) => DeleteDataStreamAsync(selector.InvokeOrDefault(new DeleteDataStreamDescriptor(name: name)), ct);
/// <summary>
/// <c>DELETE</c> request to the <c>indices.delete_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public DeleteDataStreamResponse DeleteDataStream(IDeleteDataStreamRequest request) => DoRequest<IDeleteDataStreamRequest, DeleteDataStreamResponse>(request, request.RequestParameters);
/// <summary>
/// <c>DELETE</c> request to the <c>indices.delete_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public Task<DeleteDataStreamResponse> DeleteDataStreamAsync(IDeleteDataStreamRequest request, CancellationToken ct = default) => DoRequestAsync<IDeleteDataStreamRequest, DeleteDataStreamResponse>(request, request.RequestParameters, ct);
/// <summary>
/// <c>DELETE</c> request to the <c>indices.delete_template</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html</a>
Expand Down Expand Up @@ -493,6 +565,30 @@ internal IndicesNamespace(ElasticClient client): base(client)
/// </summary>
public Task<GetAliasResponse> GetAliasAsync(IGetAliasRequest request, CancellationToken ct = default) => DoRequestAsync<IGetAliasRequest, GetAliasResponse>(request, request.RequestParameters, ct);
/// <summary>
/// <c>GET</c> request to the <c>indices.get_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public GetDataStreamResponse GetDataStream(Names name = null, Func<GetDataStreamDescriptor, IGetDataStreamRequest> selector = null) => GetDataStream(selector.InvokeOrDefault(new GetDataStreamDescriptor().Name(name: name)));
/// <summary>
/// <c>GET</c> request to the <c>indices.get_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public Task<GetDataStreamResponse> GetDataStreamAsync(Names name = null, Func<GetDataStreamDescriptor, IGetDataStreamRequest> selector = null, CancellationToken ct = default) => GetDataStreamAsync(selector.InvokeOrDefault(new GetDataStreamDescriptor().Name(name: name)), ct);
/// <summary>
/// <c>GET</c> request to the <c>indices.get_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public GetDataStreamResponse GetDataStream(IGetDataStreamRequest request) => DoRequest<IGetDataStreamRequest, GetDataStreamResponse>(request, request.RequestParameters);
/// <summary>
/// <c>GET</c> request to the <c>indices.get_data_stream</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html</a>
/// </summary>
public Task<GetDataStreamResponse> GetDataStreamAsync(IGetDataStreamRequest request, CancellationToken ct = default) => DoRequestAsync<IGetDataStreamRequest, GetDataStreamResponse>(request, request.RequestParameters, ct);
/// <summary>
/// <c>GET</c> request to the <c>indices.get_field_mapping</c> API, read more about this API online:
/// <para></para>
/// <a href = "https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html">https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html</a>
Expand Down
Loading

0 comments on commit 1645715

Please sign in to comment.