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

Ml calendar apis #3569

Merged
merged 11 commits into from
Mar 6, 2019
Next Next commit
ML Calendar APIs : Put Calendar, Put Calendar Job, Delete Calendar - …
…implemented and tested
  • Loading branch information
codebrain committed Feb 5, 2019
commit 44ae066a94d5fe70a2c5af8a70d8f93f46fe20d8
4 changes: 0 additions & 4 deletions src/CodeGeneration/ApiGenerator/ApiGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@ public class ApiGenerator
"rank_eval.json",

// these API's are new and need to be mapped
"xpack.ml.delete_calendar.json",
"xpack.ml.delete_calendar_event.json",
"xpack.ml.delete_calendar_job.json",
"xpack.ml.get_calendar_events.json",
"xpack.ml.get_calendars.json",
"xpack.ml.info.json",
"xpack.ml.post_calendar_events.json",
"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",
Expand Down
2 changes: 2 additions & 0 deletions src/CodeGeneration/ApiGenerator/Domain/ApiUrlPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public string ClrTypeName
case "type": return Type == "string" ? "TypeName" : "Types";
case "watch_id":
case "job_id":
case "calendar_id":
case "event_id":
case "datafeed_id":
case "snapshot_id":
case "filter_id":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,16 @@ public partial class CloseJobRequestParameters : RequestParameters<CloseJobReque
///<summary>Controls the time to wait until a job has closed. Default to 30 minutes</summary>
public TimeSpan Timeout { get => Q<TimeSpan>("timeout"); set => Q("timeout", value); }
}
///<summary>Request options for XpackMlDeleteCalendar<pre></pre></summary>
public partial class DeleteCalendarRequestParameters : RequestParameters<DeleteCalendarRequestParameters>
{
public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE;
}
///<summary>Request options for XpackMlDeleteCalendarEvent<pre></pre></summary>
public partial class DeleteCalendarEventRequestParameters : RequestParameters<DeleteCalendarEventRequestParameters>
{
public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE;
}
///<summary>Request options for XpackMlDeleteDatafeed<pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html</pre></summary>
public partial class DeleteDatafeedRequestParameters : RequestParameters<DeleteDatafeedRequestParameters>
{
Expand Down Expand Up @@ -2426,6 +2436,16 @@ public partial class PreviewDatafeedRequestParameters : RequestParameters<Previe
{
public override HttpMethod DefaultHttpMethod => HttpMethod.GET;
}
///<summary>Request options for XpackMlPutCalendar<pre></pre></summary>
public partial class PutCalendarRequestParameters : RequestParameters<PutCalendarRequestParameters>
{
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
}
///<summary>Request options for XpackMlPutCalendarJob<pre></pre></summary>
public partial class PutCalendarJobRequestParameters : RequestParameters<PutCalendarJobRequestParameters>
{
public override HttpMethod DefaultHttpMethod => HttpMethod.PUT;
}
///<summary>Request options for XpackMlPutDatafeed<pre>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html</pre></summary>
public partial class PutDatafeedRequestParameters : RequestParameters<PutDatafeedRequestParameters>
{
Expand Down
46 changes: 46 additions & 0 deletions src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3164,6 +3164,28 @@ public TResponse XpackMlCloseJob<TResponse>(string job_id, CloseJobRequestParame
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> XpackMlCloseJobAsync<TResponse>(string job_id, CloseJobRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(POST, Url($"_xpack/ml/anomaly_detectors/{job_id.NotNull("job_id")}/_close"), ctx, null, _params(requestParameters));
///<summary>DELETE on /_xpack/ml/calendars/{calendar_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to delete</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public TResponse XpackMlDeleteCalendar<TResponse>(string calendar_id, DeleteCalendarRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(DELETE, Url($"_xpack/ml/calendars/{calendar_id.NotNull("calendar_id")}"), null, _params(requestParameters));
///<summary>DELETE on /_xpack/ml/calendars/{calendar_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to delete</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> XpackMlDeleteCalendarAsync<TResponse>(string calendar_id, DeleteCalendarRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(DELETE, Url($"_xpack/ml/calendars/{calendar_id.NotNull("calendar_id")}"), ctx, null, _params(requestParameters));
///<summary>DELETE on /_xpack/ml/calendars/{calendar_id}/events/{event_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to modify</param>
///<param name="event_id">The ID of the event to remove from the calendar</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public TResponse XpackMlDeleteCalendarEvent<TResponse>(string calendar_id, string event_id, DeleteCalendarEventRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(DELETE, Url($"_xpack/ml/calendars/{calendar_id.NotNull("calendar_id")}/events/{event_id.NotNull("event_id")}"), null, _params(requestParameters));
///<summary>DELETE on /_xpack/ml/calendars/{calendar_id}/events/{event_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to modify</param>
///<param name="event_id">The ID of the event to remove from the calendar</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> XpackMlDeleteCalendarEventAsync<TResponse>(string calendar_id, string event_id, DeleteCalendarEventRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(DELETE, Url($"_xpack/ml/calendars/{calendar_id.NotNull("calendar_id")}/events/{event_id.NotNull("event_id")}"), ctx, null, _params(requestParameters));
///<summary>DELETE on /_xpack/ml/datafeeds/{datafeed_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html</para></summary>
///<param name="datafeed_id">The ID of the datafeed to delete</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Expand Down Expand Up @@ -3514,6 +3536,30 @@ public TResponse XpackMlPreviewDatafeed<TResponse>(string datafeed_id, PreviewDa
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> XpackMlPreviewDatafeedAsync<TResponse>(string datafeed_id, PreviewDatafeedRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(GET, Url($"_xpack/ml/datafeeds/{datafeed_id.NotNull("datafeed_id")}/_preview"), ctx, null, _params(requestParameters));
///<summary>PUT on /_xpack/ml/calendars/{calendar_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to create</param>
///<param name="body">The calendar details</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public TResponse XpackMlPutCalendar<TResponse>(string calendar_id, PostData body, PutCalendarRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(PUT, Url($"_xpack/ml/calendars/{calendar_id.NotNull("calendar_id")}"), body, _params(requestParameters));
///<summary>PUT on /_xpack/ml/calendars/{calendar_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to create</param>
///<param name="body">The calendar details</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> XpackMlPutCalendarAsync<TResponse>(string calendar_id, PostData body, PutCalendarRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(PUT, Url($"_xpack/ml/calendars/{calendar_id.NotNull("calendar_id")}"), ctx, body, _params(requestParameters));
///<summary>PUT on /_xpack/ml/calendars/{calendar_id}/jobs/{job_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to modify</param>
///<param name="job_id">The ID of the job to add to the calendar</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public TResponse XpackMlPutCalendarJob<TResponse>(string calendar_id, string job_id, PutCalendarJobRequestParameters requestParameters = null)
where TResponse : class, IElasticsearchResponse, new() => this.DoRequest<TResponse>(PUT, Url($"_xpack/ml/calendars/{calendar_id.NotNull("calendar_id")}/jobs/{job_id.NotNull("job_id")}"), null, _params(requestParameters));
///<summary>PUT on /_xpack/ml/calendars/{calendar_id}/jobs/{job_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to modify</param>
///<param name="job_id">The ID of the job to add to the calendar</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<TResponse> XpackMlPutCalendarJobAsync<TResponse>(string calendar_id, string job_id, PutCalendarJobRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken))
where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync<TResponse>(PUT, Url($"_xpack/ml/calendars/{calendar_id.NotNull("calendar_id")}/jobs/{job_id.NotNull("job_id")}"), ctx, null, _params(requestParameters));
///<summary>PUT on /_xpack/ml/datafeeds/{datafeed_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html</para></summary>
///<param name="datafeed_id">The ID of the datafeed to create</param>
///<param name="body">The datafeed config</param>
Expand Down
38 changes: 38 additions & 0 deletions src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,24 @@ public partial interface IElasticLowLevelClient
///<param name="job_id">The name of the job to close</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> XpackMlCloseJobAsync<TResponse>(string job_id, CloseJobRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_xpack/ml/calendars/{calendar_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to delete</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
TResponse XpackMlDeleteCalendar<TResponse>(string calendar_id, DeleteCalendarRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_xpack/ml/calendars/{calendar_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to delete</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> XpackMlDeleteCalendarAsync<TResponse>(string calendar_id, DeleteCalendarRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_xpack/ml/calendars/{calendar_id}/events/{event_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to modify</param>
///<param name="event_id">The ID of the event to remove from the calendar</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
TResponse XpackMlDeleteCalendarEvent<TResponse>(string calendar_id, string event_id, DeleteCalendarEventRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_xpack/ml/calendars/{calendar_id}/events/{event_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to modify</param>
///<param name="event_id">The ID of the event to remove from the calendar</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> XpackMlDeleteCalendarEventAsync<TResponse>(string calendar_id, string event_id, DeleteCalendarEventRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>DELETE on /_xpack/ml/datafeeds/{datafeed_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html</para></summary>
///<param name="datafeed_id">The ID of the datafeed to delete</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Expand Down Expand Up @@ -2846,6 +2864,26 @@ public partial interface IElasticLowLevelClient
///<param name="datafeed_id">The ID of the datafeed to preview</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> XpackMlPreviewDatafeedAsync<TResponse>(string datafeed_id, PreviewDatafeedRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>PUT on /_xpack/ml/calendars/{calendar_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to create</param>
///<param name="body">The calendar details</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
TResponse XpackMlPutCalendar<TResponse>(string calendar_id, PostData body, PutCalendarRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
///<summary>PUT on /_xpack/ml/calendars/{calendar_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to create</param>
///<param name="body">The calendar details</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> XpackMlPutCalendarAsync<TResponse>(string calendar_id, PostData body, PutCalendarRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>PUT on /_xpack/ml/calendars/{calendar_id}/jobs/{job_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to modify</param>
///<param name="job_id">The ID of the job to add to the calendar</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
TResponse XpackMlPutCalendarJob<TResponse>(string calendar_id, string job_id, PutCalendarJobRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new();
///<summary>PUT on /_xpack/ml/calendars/{calendar_id}/jobs/{job_id} <para></para></summary>
///<param name="calendar_id">The ID of the calendar to modify</param>
///<param name="job_id">The ID of the job to add to the calendar</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
Task<TResponse> XpackMlPutCalendarJobAsync<TResponse>(string calendar_id, string job_id, PutCalendarJobRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new();
///<summary>PUT on /_xpack/ml/datafeeds/{datafeed_id} <para>http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html</para></summary>
///<param name="datafeed_id">The ID of the datafeed to create</param>
///<param name="body">The datafeed config</param>
Expand Down
2 changes: 2 additions & 0 deletions src/Nest/CommonAbstractions/Request/RouteValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class RouteValues
public string Fields => GetResolved("fields");
public string FilterId => GetResolved("filter_id");
public string Id => GetResolved("id");
public string CalendarId => GetResolved("calendar_id");
public string EventId => GetResolved("event_id");

public string Index => GetResolved("index");
public string IndexMetric => GetResolved("index_metric");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public PutMappingDescriptor(IndexName index, TypeName type) : base(r => r.Requir

/// <summary>
/// Convenience method to map as much as it can based on ElasticType attributes set on the type.
/// <pre>This method also automatically sets up mappings for known values types (int, long, double, datetime, etcetera)</pre>
/// <pre>This method also automatically sets up mappings for primitive values types (e.g. int, long, double, DateTime...)</pre>
/// <pre>Class types default to object and Enums to int</pre>
/// <pre>Later calls can override whatever is set is by this call.</pre>
/// <pre>Later calls can override whatever is set by this call.</pre>
/// </summary>
public PutMappingDescriptor<T> AutoMap(IPropertyVisitor visitor = null, int maxRecursion = 0) =>
Assign(a => a.Properties = a.Properties.AutoMap<T>(visitor, maxRecursion));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Nest
{
public partial interface IDeleteCalendarRequest { }

public partial class DeleteCalendarRequest { }

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

public class DeleteCalendarResponse : AcknowledgedResponseBase, IDeleteCalendarResponse { }
}
Loading