Skip to content

Delete forecast API #3591

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 11 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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/CodeGeneration/ApiGenerator/ApiGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class ApiGenerator
"xpack.ml.put_calendar.json",
"xpack.ml.put_calendar_job.json",
"xpack.ml.get_calendar_job.json",
"xpack.ml.delete_forecast.json",
"xpack.ml.find_file_structure.json",
"delete_by_query_rethrottle.json",
"update_by_query_rethrottle.json",
Expand Down
1 change: 1 addition & 0 deletions src/CodeGeneration/ApiGenerator/Domain/ApiUrlPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public string ClrTypeName
case "datafeed_id":
case "snapshot_id":
case "filter_id":
case "forecast_id":
case "id": return Type == "string" ? "Id" : "Ids";
case "category_id": return "CategoryId";
case "nodes":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"xpack.ml.delete_forecast": {
"url": {
"path": "/_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id}",
"paths": [
"/_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id}"
],
"parts": {
"forecast_id": {
"required": true,
"description": "The ID of the forecast to delete, can be comma delimited list or `_all`"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2323,6 +2323,15 @@ public partial class DeleteExpiredDataRequestParameters : RequestParameters<Dele
{
public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE;
}
///<summary>Request options for XpackMlDeleteForecast<pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html</pre></summary>
public partial class DeleteForecastRequestParameters : RequestParameters<DeleteForecastRequestParameters>
{
public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE;
///<summary>Whether to ignore if `_all` matches no forecasts</summary>
public bool? AllowNoForecasts { get => Q<bool?>("allow_no_forecasts"); set => Q("allow_no_forecasts", value); }
///<summary>Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds</summary>
public TimeSpan Timeout { get => Q<TimeSpan>("timeout"); set => Q("timeout", value); }
}
///<summary>Request options for XpackMlDeleteJob<pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html</pre></summary>
public partial class DeleteJobRequestParameters : RequestParameters<DeleteJobRequestParameters>
{
Expand Down
12 changes: 12 additions & 0 deletions src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3182,6 +3182,18 @@ public TResponse XpackMlDeleteExpiredData<TResponse>(DeleteExpiredDataRequestPar
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> XpackMlDeleteExpiredDataAsync<TResponse>(DeleteExpiredDataRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(DELETE, Url($"_xpack/ml/_delete_expired_data"), ctx, null, _params(requestParameters));
///<summary>DELETE on /_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html</para></summary>
///<param name="job_id">The ID of the job from which to delete forecasts</param>
///<param name="forecast_id">The ID of the forecast to delete, can be comma delimited list or `_all`</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public TResponse XpackMlDeleteForecast<TResponse>(string job_id, string forecast_id, DeleteForecastRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(DELETE, Url($"_xpack/ml/anomaly_detectors/{job_id.NotNull("job_id")}/_forecast/{forecast_id.NotNull("forecast_id")}"), null, _params(requestParameters));
///<summary>DELETE on /_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html</para></summary>
///<param name="job_id">The ID of the job from which to delete forecasts</param>
///<param name="forecast_id">The ID of the forecast to delete, can be comma delimited list or `_all`</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> XpackMlDeleteForecastAsync<TResponse>(string job_id, string forecast_id, DeleteForecastRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(DELETE, Url($"_xpack/ml/anomaly_detectors/{job_id.NotNull("job_id")}/_forecast/{forecast_id.NotNull("forecast_id")}"), ctx, null, _params(requestParameters));
///<summary>DELETE on /_xpack/ml/anomaly_detectors/{job_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html</para></summary>
///<param name="job_id">The ID of the job to delete</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Expand Down
10 changes: 10 additions & 0 deletions src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,16 @@ public partial interface IElasticLowLevelClient
///<summary>DELETE on /_xpack/ml/_delete_expired_data <para></para></summary>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> XpackMlDeleteExpiredDataAsync<TResponse>(DeleteExpiredDataRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html</para></summary>
///<param name="job_id">The ID of the job from which to delete forecasts</param>
///<param name="forecast_id">The ID of the forecast to delete, can be comma delimited list or `_all`</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
TResponse XpackMlDeleteForecast<TResponse>(string job_id, string forecast_id, DeleteForecastRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html</para></summary>
///<param name="job_id">The ID of the job from which to delete forecasts</param>
///<param name="forecast_id">The ID of the forecast to delete, can be comma delimited list or `_all`</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> XpackMlDeleteForecastAsync<TResponse>(string job_id, string forecast_id, DeleteForecastRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_xpack/ml/anomaly_detectors/{job_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html</para></summary>
///<param name="job_id">The ID of the job to delete</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Expand Down
1 change: 1 addition & 0 deletions src/Nest/CommonAbstractions/Request/RouteValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class RouteValues
public string ActionId => GetResolved("action_id");
public string Alias => GetResolved("alias");
public string CategoryId => GetResolved("category_id");
public string ForecastId => GetResolved("forecast_id");
public string Context => GetResolved("context");
public string DatafeedId => GetResolved("datafeed_id");
public string Feature => GetResolved("feature");
Expand Down
9 changes: 7 additions & 2 deletions src/Nest/Document/Multiple/Bulk/BulkRequestJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
op.Routing = op.GetRoutingForOperation(settings.Inferrer);

var opJson = requestResponseSerializer.SerializeToString(op, SerializationFormatting.None);
writer.WriteRaw($"{{\"{op.Operation}\":" + opJson + "}\n");
writer.WriteRaw("{\"");
writer.WriteRaw(op.Operation);
writer.WriteRaw("\":");
writer.WriteRaw(opJson);
writer.WriteRaw("}\n");
var body = op.GetBody();
if (body == null) continue;

Expand All @@ -40,7 +44,8 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
)
.SerializeToString(body, SerializationFormatting.None);

writer.WriteRaw(bodyJson + "\n");
writer.WriteRaw(bodyJson);
writer.WriteRaw("\n");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Nest
{
public partial interface IDeleteForecastRequest { }

public partial class DeleteForecastRequest { }

[DescriptorFor("XpackMlDeleteForecast")]
public partial class DeleteForecastDescriptor { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Nest
{
public interface IDeleteForecastResponse : IAcknowledgedResponse { }

public class DeleteForecastResponse : AcknowledgedResponseBase, IDeleteForecastResponse { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Elasticsearch.Net;

namespace Nest
{
public partial interface IElasticClient
{
/// <summary>
/// Deletes forecasts from a machine learning job.
/// </summary>
IDeleteForecastResponse DeleteForecast(Id jobId, Id forecastId, Func<DeleteForecastDescriptor, IDeleteForecastRequest> selector = null);

/// <inheritdoc cref="DeleteForecast(Nest.IdNest.Id,System.Func{Nest.DeleteForecastDescriptor,Nest.IDeleteForecastRequest})" />
IDeleteForecastResponse DeleteForecast(IDeleteForecastRequest request);

/// <inheritdoc cref="DeleteForecast(Nest.IdNest.Id,System.Func{Nest.DeleteForecastDescriptor,Nest.IDeleteForecastRequest})" />
Task<IDeleteForecastResponse> DeleteForecastAsync(Id jobId, Id forecastId, Func<DeleteForecastDescriptor, IDeleteForecastRequest> selector = null,
CancellationToken cancellationToken = default(CancellationToken)
);

/// <inheritdoc cref="DeleteForecast(Nest.IdNest.Id,System.Func{Nest.DeleteForecastDescriptor,Nest.IDeleteForecastRequest})" />
Task<IDeleteForecastResponse> DeleteForecastAsync(IDeleteForecastRequest request,
CancellationToken cancellationToken = default(CancellationToken)
);
}

public partial class ElasticClient
{
/// <inheritdoc cref="DeleteForecast(Nest.IdNest.Id,System.Func{Nest.DeleteForecastDescriptor,Nest.IDeleteForecastRequest})" />
public IDeleteForecastResponse DeleteForecast(Id jobId, Id forecastId, Func<DeleteForecastDescriptor, IDeleteForecastRequest> selector = null) =>
DeleteForecast(selector.InvokeOrDefault(new DeleteForecastDescriptor(jobId, forecastId)));

/// <inheritdoc cref="DeleteForecast(Nest.IdNest.Id,System.Func{Nest.DeleteForecastDescriptor,Nest.IDeleteForecastRequest})" />
public IDeleteForecastResponse DeleteForecast(IDeleteForecastRequest request) =>
Dispatcher.Dispatch<IDeleteForecastRequest, DeleteForecastRequestParameters, DeleteForecastResponse>(
request,
(p, d) => LowLevelDispatch.XpackMlDeleteForecastDispatch<DeleteForecastResponse>(p)
);

/// <inheritdoc cref="DeleteForecast(Nest.IdNest.Id,System.Func{Nest.DeleteForecastDescriptor,Nest.IDeleteForecastRequest})" />
public Task<IDeleteForecastResponse> DeleteForecastAsync(Id jobId, Id forecastId,
Func<DeleteForecastDescriptor, IDeleteForecastRequest> selector = null, CancellationToken cancellationToken = default(CancellationToken)) =>
DeleteForecastAsync(selector.InvokeOrDefault(new DeleteForecastDescriptor(jobId, forecastId)), cancellationToken);

/// <inheritdoc cref="DeleteForecast(Nest.IdNest.Id,System.Func{Nest.DeleteForecastDescriptor,Nest.IDeleteForecastRequest})" />
public Task<IDeleteForecastResponse> DeleteForecastAsync(IDeleteForecastRequest request,
CancellationToken cancellationToken = default(CancellationToken)) =>
Dispatcher.DispatchAsync<IDeleteForecastRequest, DeleteForecastRequestParameters, DeleteForecastResponse, IDeleteForecastResponse>(
request,
cancellationToken,
(p, d, c) => LowLevelDispatch.XpackMlDeleteForecastDispatchAsync<DeleteForecastResponse>(p, c)
);
}
}
18 changes: 18 additions & 0 deletions src/Nest/_Generated/_Descriptors.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4136,6 +4136,24 @@ public partial class DeleteExpiredDataDescriptor : RequestDescriptorBase<Delete
// Request parameters

}
///<summary>descriptor for XpackMlDeleteForecast <pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html</pre></summary>
public partial class DeleteForecastDescriptor : RequestDescriptorBase<DeleteForecastDescriptor,DeleteForecastRequestParameters, IDeleteForecastRequest>, IDeleteForecastRequest
{
/// <summary>/_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id}</summary>
///<param name="job_id"> this parameter is required</param>
///<param name="forecast_id"> this parameter is required</param>
public DeleteForecastDescriptor(Id job_id, Id forecast_id) : base(r=>r.Required("job_id", job_id).Required("forecast_id", forecast_id)){}
// values part of the url path
Id IDeleteForecastRequest.JobId => Self.RouteValues.Get<Id>("job_id");
Id IDeleteForecastRequest.ForecastId => Self.RouteValues.Get<Id>("forecast_id");

// Request parameters

///<summary>Whether to ignore if `_all` matches no forecasts</summary>
public DeleteForecastDescriptor AllowNoForecasts(bool? allowNoForecasts = true) => Qs("allow_no_forecasts", allowNoForecasts);
///<summary>Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds</summary>
public DeleteForecastDescriptor Timeout(Time timeout) => Qs("timeout", timeout);
}
///<summary>descriptor for XpackMlDeleteJob <pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html</pre></summary>
public partial class DeleteJobDescriptor : RequestDescriptorBase<DeleteJobDescriptor,DeleteJobRequestParameters, IDeleteJobRequest>, IDeleteJobRequest
{
Expand Down
22 changes: 22 additions & 0 deletions src/Nest/_Generated/_LowLevelDispatch.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3396,6 +3396,28 @@ internal partial class LowLevelDispatch
throw InvalidDispatch("XpackMlDeleteExpiredData", p, new [] { DELETE }, "/_xpack/ml/_delete_expired_data");
}

internal TResponse XpackMlDeleteForecastDispatch<TResponse>(IRequest<DeleteForecastRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
{
switch(p.HttpMethod)
{
case DELETE:
if (AllSetNoFallback(p.RouteValues.JobId, p.RouteValues.ForecastId)) return _lowLevel.XpackMlDeleteForecast<TResponse>(p.RouteValues.JobId,p.RouteValues.ForecastId,p.RequestParameters);
break;
}
throw InvalidDispatch("XpackMlDeleteForecast", p, new [] { DELETE }, "/_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id}");
}

internal Task<TResponse> XpackMlDeleteForecastDispatchAsync<TResponse>(IRequest<DeleteForecastRequestParameters> p, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new()
{
switch(p.HttpMethod)
{
case DELETE:
if (AllSetNoFallback(p.RouteValues.JobId, p.RouteValues.ForecastId)) return _lowLevel.XpackMlDeleteForecastAsync<TResponse>(p.RouteValues.JobId,p.RouteValues.ForecastId,p.RequestParameters,ct);
break;
}
throw InvalidDispatch("XpackMlDeleteForecast", p, new [] { DELETE }, "/_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id}");
}

internal TResponse XpackMlDeleteJobDispatch<TResponse>(IRequest<DeleteJobRequestParameters> p) where TResponse : class, IElasticsearchResponse, new()
{
switch(p.HttpMethod)
Expand Down
48 changes: 36 additions & 12 deletions src/Nest/_Generated/_Requests.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,30 @@ public partial class DeleteExpiredDataRequest : PlainRequestBase<DeleteExpiredDa
// Request parameters
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public partial interface IDeleteForecastRequest : IRequest<DeleteForecastRequestParameters>
{
Id JobId { get; }
Id ForecastId { get; }
}
///<summary>Request parameters for XpackMlDeleteForecast <pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html</pre></summary>
public partial class DeleteForecastRequest : PlainRequestBase<DeleteForecastRequestParameters>, IDeleteForecastRequest
{
protected IDeleteForecastRequest Self => this;
///<summary>/_xpack/ml/anomaly_detectors/{job_id}/_forecast/{forecast_id}</summary>
///<param name="job_id">this parameter is required</param>
///<param name="forecast_id">this parameter is required</param>
public DeleteForecastRequest(Id job_id, Id forecast_id) : base(r=>r.Required("job_id", job_id).Required("forecast_id", forecast_id)){}
// values part of the url path
Id IDeleteForecastRequest.JobId => Self.RouteValues.Get<Id>("job_id");
Id IDeleteForecastRequest.ForecastId => Self.RouteValues.Get<Id>("forecast_id");

// Request parameters
///<summary>Whether to ignore if `_all` matches no forecasts</summary>
public bool? AllowNoForecasts { get => Q<bool?>("allow_no_forecasts"); set => Q("allow_no_forecasts", value); }
///<summary>Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds</summary>
public Time Timeout { get => Q<Time>("timeout"); set => Q("timeout", value); }
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public partial interface IDeleteIndexRequest : IRequest<DeleteIndexRequestParameters>
{
Indices Index { get; }
Expand Down Expand Up @@ -2673,18 +2697,6 @@ public GetAnomalyRecordsRequest(Id job_id) : base(r=>r.Required("job_id", job_id
// Request parameters
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public partial interface IGetBasicLicenseStatusRequest : IRequest<GetBasicLicenseStatusRequestParameters>
{
}
///<summary>Request parameters for XpackLicenseGetBasicStatus <pre>https://www.elastic.co/guide/en/x-pack/current/license-management.html</pre></summary>
public partial class GetBasicLicenseStatusRequest : PlainRequestBase<GetBasicLicenseStatusRequestParameters>, IGetBasicLicenseStatusRequest
{
protected IGetBasicLicenseStatusRequest Self => this;
// values part of the url path

// Request parameters
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public partial interface IGetAutoFollowPatternRequest : IRequest<GetAutoFollowPatternRequestParameters>
{
Name Name { get; }
Expand All @@ -2704,6 +2716,18 @@ public GetAutoFollowPatternRequest(Name name) : base(r=>r.Optional("name", name)
// Request parameters
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public partial interface IGetBasicLicenseStatusRequest : IRequest<GetBasicLicenseStatusRequestParameters>
{
}
///<summary>Request parameters for XpackLicenseGetBasicStatus <pre>https://www.elastic.co/guide/en/x-pack/current/license-management.html</pre></summary>
public partial class GetBasicLicenseStatusRequest : PlainRequestBase<GetBasicLicenseStatusRequestParameters>, IGetBasicLicenseStatusRequest
{
protected IGetBasicLicenseStatusRequest Self => this;
// values part of the url path

// Request parameters
}
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public partial interface IGetBucketsRequest : IRequest<GetBucketsRequestParameters>
{
Id JobId { get; }
Expand Down
Loading