diff --git a/src/ApiGenerator/Configuration/CodeConfiguration.cs b/src/ApiGenerator/Configuration/CodeConfiguration.cs index 12548b5ad8e..39d3f77ec99 100644 --- a/src/ApiGenerator/Configuration/CodeConfiguration.cs +++ b/src/ApiGenerator/Configuration/CodeConfiguration.cs @@ -60,7 +60,6 @@ public static class CodeConfiguration "async_search.submit.json", "cat.ml_data_frame_analytics.json", "cat.ml_datafeeds.json", - "cat.ml_jobs.json", "cluster.delete_component_template.json", "cluster.get_component_template.json", "cluster.put_component_template.json", diff --git a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Cat.cs b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Cat.cs index 61552384d77..31420244d36 100644 --- a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Cat.cs +++ b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Cat.cs @@ -635,8 +635,8 @@ public bool? Verbose } } - ///Request options for MlJobs https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html - public class MlJobsRequestParameters : RequestParameters + ///Request options for Jobs https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + public class CatJobsRequestParameters : RequestParameters { public override HttpMethod DefaultHttpMethod => HttpMethod.GET; ///Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.Cat.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.Cat.cs index 8411d86927b..edf891aaabc 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.Cat.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.Cat.cs @@ -218,23 +218,23 @@ public Task MlDatafeedsAsync(string datafeedId, MlDatafeed where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, Url($"_cat/ml/datafeeds/{datafeedId:datafeedId}"), ctx, null, RequestParams(requestParameters)); ///GET on /_cat/ml/anomaly_detectors https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html ///Request specific configuration such as querystring parameters & request specific connection settings. - public TResponse MlJobs(MlJobsRequestParameters requestParameters = null) + public TResponse Jobs(CatJobsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new() => DoRequest(GET, "_cat/ml/anomaly_detectors", null, RequestParams(requestParameters)); ///GET on /_cat/ml/anomaly_detectors https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html ///Request specific configuration such as querystring parameters & request specific connection settings. [MapsApi("cat.ml_jobs", "")] - public Task MlJobsAsync(MlJobsRequestParameters requestParameters = null, CancellationToken ctx = default) + public Task JobsAsync(CatJobsRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, "_cat/ml/anomaly_detectors", ctx, null, RequestParams(requestParameters)); ///GET on /_cat/ml/anomaly_detectors/{job_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html ///The ID of the jobs stats to fetch ///Request specific configuration such as querystring parameters & request specific connection settings. - public TResponse MlJobs(string jobId, MlJobsRequestParameters requestParameters = null) + public TResponse Jobs(string jobId, CatJobsRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new() => DoRequest(GET, Url($"_cat/ml/anomaly_detectors/{jobId:jobId}"), null, RequestParams(requestParameters)); ///GET on /_cat/ml/anomaly_detectors/{job_id} https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html ///The ID of the jobs stats to fetch ///Request specific configuration such as querystring parameters & request specific connection settings. [MapsApi("cat.ml_jobs", "job_id")] - public Task MlJobsAsync(string jobId, MlJobsRequestParameters requestParameters = null, CancellationToken ctx = default) + public Task JobsAsync(string jobId, CatJobsRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, Url($"_cat/ml/anomaly_detectors/{jobId:jobId}"), ctx, null, RequestParams(requestParameters)); ///GET on /_cat/ml/trained_models https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html ///Request specific configuration such as querystring parameters & request specific connection settings. diff --git a/src/Nest/Cat/CatJobs/CatJobsRecord.cs b/src/Nest/Cat/CatJobs/CatJobsRecord.cs new file mode 100644 index 00000000000..204f7b84926 --- /dev/null +++ b/src/Nest/Cat/CatJobs/CatJobsRecord.cs @@ -0,0 +1,362 @@ +using System.Runtime.Serialization; +using Elasticsearch.Net.Utf8Json; + +namespace Nest +{ + [DataContract] + public class CatJobsRecord : ICatRecord + { + /// + /// For open anomaly detection jobs only, contains messages relating to the selection of a node to run the job. + /// + [DataMember(Name ="assignment_explanation")] + public string AssignmentExplanation { get; set; } + + /// + /// (Default) The number of bucket results produced by the job. + /// + [DataMember(Name ="buckets.count")] + public string BucketsCount { get; set; } + + /// + /// Exponential moving average of all bucket processing times, in milliseconds. + /// + [DataMember(Name ="buckets.time.exp_avg")] + public string BucketsTimeExpAvg { get; set; } + + /// + /// Exponentially-weighted moving average of bucket processing times calculated in a 1 hour time window, in milliseconds. + /// + [DataMember(Name ="buckets.time.exp_avg_hour")] + public string BucketsTimeExpAvgHour { get; set; } + + /// + /// Maximum among all bucket processing times, in milliseconds. + /// + [DataMember(Name ="buckets.time.max")] + public string BucketsTimeMax { get; set; } + + /// + /// Minimum among all bucket processing times, in milliseconds. + /// + [DataMember(Name ="buckets.time.min")] + public string BucketsTimeMin { get; set; } + + /// + /// Sum of all bucket processing times, in milliseconds. + /// + [DataMember(Name ="buckets.time.total")] + public string BucketsTimeTotal { get; set; } + + /// + /// The number of buckets processed. + /// + [DataMember(Name ="data.buckets")] + public string DataBuckets { get; set; } + + /// + /// The timestamp of the earliest chronologically input document. + /// + [DataMember(Name ="data.earliest_record")] + public string DataEarliestRecord { get; set; } + + /// + /// The number of buckets which did not contain any data. If your data contains many empty buckets, consider increasing your bucket_span + /// or using functions that are tolerant to gaps in data such as mean, non_null_sum or non_zero_count. + /// + [DataMember(Name ="data.empty_buckets")] + public string DataEmptyBuckets { get; set; } + + /// + /// The number of bytes of input data posted to the anomaly detection job. + /// + [DataMember(Name ="data.input_bytes")] + public string DataInputBytes { get; set; } + + /// + /// The total number of fields in input documents posted to the anomaly detection job. This count includes fields that are not used in the + /// analysis. However, be aware that if you are using a datafeed, it extracts only the required fields from the documents it retrieves + /// before posting them to the job. + /// + [DataMember(Name ="data.input_fields")] + public string DataInputFields { get; set; } + + /// + /// The number of input documents posted to the anomaly detection job. + /// + [DataMember(Name ="data.input_records")] + public string DataInputRecords { get; set; } + + /// + /// The number of input documents with either a missing date field or a date that could not be parsed. + /// + [DataMember(Name ="data.invalid_dates")] + public string DataInvalidDates { get; set; } + + /// + /// The timestamp at which data was last analyzed, according to server time. + /// + [DataMember(Name ="data.last")] + public string DataLast { get; set; } + + /// + /// The timestamp of the last bucket that did not contain any data. + /// + [DataMember(Name ="data.last_empty_bucket")] + public string DataLastEmptyBucket { get; set; } + + /// + /// The timestamp of the last bucket that was considered sparse. + /// + [DataMember(Name ="data.last_sparse_bucket")] + public string DataLastSparseBucket { get; set; } + + /// + /// The timestamp of the latest chronologically input document. + /// + [DataMember(Name ="data.latest_record")] + public string DataLatestRecord { get; set; } + + /// + /// The number of input documents that are missing a field that the anomaly detection job is configured to analyze. Input documents + /// with missing fields are still processed because it is possible that not all fields are missing. + /// + /// Note: If you are using datafeeds or posting data to the job in JSON format, a high missing_field_count is often not an indication + /// of data issues. It is not necessarily a cause for concern. + /// + [DataMember(Name ="data.missing_fields")] + public string DataMissingFields { get; set; } + + /// + /// The number of input documents that are out of time sequence and outside of the latency window. This information is applicable + /// only when you provide data to the anomaly detection job by using the post data API. These out of order documents are discarded, + /// since jobs require time series data to be in ascending chronological order. + /// + [DataMember(Name ="data.out_of_order_timestamps")] + public string DataOutOfOrderTimestamps { get; set; } + + /// + /// The total number of fields in all the documents that have been processed by the anomaly detection job. Only fields that are specified + /// in the detector configuration object contribute to this count. The timestamp is not included in this count. + /// + [DataMember(Name ="data.processed_fields")] + public string DataProcessedFields { get; set; } + + /// + /// (Default) The number of input documents that have been processed by the anomaly detection job. This value includes documents with + /// missing fields, since they are nonetheless analyzed. If you use datafeeds and have aggregations in your search query, the + /// processed_record_count is the number of aggregation results processed, not the number of Elasticsearch documents. + /// + [DataMember(Name ="data.processed_records")] + public string DataProcessedRecords { get; set; } + + /// + /// The number of buckets that contained few data points compared to the expected number of data points. If your data contains many + /// sparse buckets, consider using a longer bucket_span. + /// + [DataMember(Name ="data.sparse_buckets")] + public string DataSparseBuckets { get; set; } + + /// + /// The average memory usage in bytes for forecasts related to the job. + /// + [DataMember(Name="forecasts.memory.avg")] + public string ForecastsMemoryAvg { get; internal set; } + + /// + /// The maximum memory usage in bytes for forecasts related to the job. + /// + [DataMember(Name="forecasts.memory.min")] + public string ForecastsMemoryMin { get; internal set; } + + /// + /// The total memory usage in bytes for forecasts related to the job. + /// + [DataMember(Name="forecasts.memory.total")] + public string ForecastsMemoryTotal { get; internal set; } + + /// + /// The average number of `model_forecast` documents written for forecasts related to the job. + /// + [DataMember(Name="forecasts.records.avg")] + public string ForecastsRecordsAvg { get; internal set; } + + /// + /// The maximum number of `model_forecast` documents written for forecasts related to the job. + /// + [DataMember(Name="forecasts.records.max")] + public string ForecastsRecordsMax { get; internal set; } + + /// + /// The minimum number of `model_forecast` documents written for forecasts relatedto the job. + /// + [DataMember(Name="forecasts.records.min")] + public string ForecastsRecordsMin { get; internal set; } + + /// + /// The total number of `model_forecast` documents written for forecasts related to the job. + /// + [DataMember(Name="forecasts.records.total")] + public string ForecastsRecordsTotal { get; internal set; } + + /// + /// The average runtime in milliseconds for forecasts related to the job. + /// + [DataMember(Name="forecasts.time.avg")] + public string ForecastsTimeAvg { get; internal set; } + + /// + /// The maximum runtime in milliseconds for forecasts related to the job. + /// + [DataMember(Name="forecasts.time.max")] + public string ForecastsTimeMax { get; internal set; } + + /// + /// The minimum runtime in milliseconds for forecasts related to the job. + /// + [DataMember(Name="forecasts.time.min")] + public string ForecastsTimeMin { get; internal set; } + + /// + /// The total runtime in milliseconds for forecasts related to the job.(Default) + /// + [DataMember(Name="forecasts.total")] + public string ForecastsTotal { get; internal set; } + + /// + /// (Default) Identifier for the anomaly detection job. + /// + [DataMember(Name="id")] + public string Id { get; internal set; } + + /// + /// The number of buckets for which new entities in incoming data were not processed due to insufficient model memory. This situation is also + /// signified by a hard_limit: memory_status property value. + /// + [DataMember(Name="model.bucket_allocation_failures")] + public string ModelBucketAllocationFailures { get; internal set; } + + /// + /// The number of by field values that were analyzed by the models. This value is cumulative for all detectors in the job. + /// + [DataMember(Name="model.by_fields")] + public string ModelByFields { get; internal set; } + + /// + /// (Default) The number of bytes of memory used by the models. This is the maximum value since the last time the model was persisted. + /// If the job is closed, this value indicates the latest size. + /// + [DataMember(Name="model.bytes")] + public string ModelBytes { get; internal set; } + + /// + /// The number of bytes over the high limit for memory usage at the last allocation failure. + /// + [DataMember(Name="model.bytes")] + public string ModelBytesExceeded { get; internal set; } + + /// + /// The status of categorization for the job. + /// + [DataMember(Name="model.categorization_status")] + public ModelCategorizationStatus ModelCategorizationStatus { get; internal set; } + + /// + /// The number of documents that have had a field categorized. + /// + [DataMember(Name="model.categorized_doc_count")] + public string ModelCategorizedDocCount { get; internal set; } + + /// + /// The number of categories created by categorization that will never be assigned again because another category’s definition makes it a + /// superset of the dead category. (Dead categories are a side effect of the way categorization has no prior training.) + /// + [DataMember(Name="model.dead_category_count")] + public string ModelDeadCategoryCount { get; internal set; } + + /// + /// The number of categories that match more than 1% of categorized documents. + /// + [DataMember(Name="model.frequent_category_count")] + public string ModelFrequentCategoryCount { get; internal set; } + + /// + /// The timestamp when the model stats were gathered, according to server time. + /// + [DataMember(Name="model.log_time")] + public string ModelLogTime { get; internal set; } + + /// + /// The upper limit for model memory usage, checked on increasing values. + /// + [DataMember(Name="model.memory_limit")] + public string ModelMemoryLimit { get; internal set; } + + /// + /// (Default) The status of the mathematical models. + /// + [DataMember(Name="model.memory_status")] + public ModelMemoryStatus ModelMemoryStatus { get; internal set; } + + /// + /// The number of over field values that were analyzed by the models. This value is cumulative for all detectors in the job. + /// + [DataMember(Name="model.over_fields")] + public string ModelOverFields { get; internal set; } + + /// + /// The number of partition field values that were analyzed by the models. This value is cumulative for all detectors in the job. + /// + [DataMember(Name="model.partition_fields")] + public string ModelPartitionFields { get; internal set; } + + /// + /// The number of categories that match just one categorized document. + /// + [DataMember(Name="model.rare_category_count")] + public string ModelRareCategoryCount { get; internal set; } + + /// + /// The timestamp of the last record when the model stats were gathered. + /// + [DataMember(Name="model.timestamp")] + public string ModelTimestamp { get; internal set; } + + /// + /// The network address of the node. Contains properties for the node that runs the job. This information is available only for open jobs. + /// + [DataMember(Name="node.address")] + public string NodeAddress { get; internal set; } + + /// + /// The ephemeral ID of the node.The unique identifier of the node. Contains properties for the node that runs the job. This information + /// is available only for open jobs. + /// + [DataMember(Name="node.ephemeral_id")] + public string NodeEphemeralId { get; internal set; } + + /// + /// The unique identifier of the node. Contains properties for the node that runs the job. This information is available only for open jobs. + /// + [DataMember(Name="node.id")] + public string NodeId { get; internal set; } + + /// + /// The node name. Contains properties for the node that runs the job. This information is available only for open jobs. + /// + [DataMember(Name="node.name")] + public string NodeName { get; internal set; } + + /// + /// For open jobs only, the elapsed time for which the job has been open. + /// + [DataMember(Name="opened_time")] + public string OpenedTime { get; internal set; } + + /// + /// (Default) The status of the anomaly detection job. + /// + [DataMember(Name="state")] + public JobState State { get; internal set; } + } +} diff --git a/src/Nest/Cat/CatJobs/CatJobsRequest.cs b/src/Nest/Cat/CatJobs/CatJobsRequest.cs new file mode 100644 index 00000000000..135b6dfb9f6 --- /dev/null +++ b/src/Nest/Cat/CatJobs/CatJobsRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + [MapsApi("cat.ml_jobs.json")] + public partial interface ICatJobsRequest { } + + public partial class CatJobsRequest { } + + public partial class CatJobsDescriptor { } +} diff --git a/src/Nest/Cat/CatJobs/ModelCategorizationStatus.cs b/src/Nest/Cat/CatJobs/ModelCategorizationStatus.cs new file mode 100644 index 00000000000..e52d1035382 --- /dev/null +++ b/src/Nest/Cat/CatJobs/ModelCategorizationStatus.cs @@ -0,0 +1,27 @@ +using System.Runtime.Serialization; +using Elasticsearch.Net; + +namespace Nest +{ + /// + /// The status of categorization for the job. + /// + [StringEnum] + public enum ModelCategorizationStatus + { + /// + /// Categorization is performing acceptably well (or not being used at all). + /// + [EnumMember(Value = "ok")] + OK, + + /// + /// Categorization is detecting a distribution of categories that suggests the input data is inappropriate for categorization. + /// Problems could be that there is only one category, more than 90% of categories are rare, the number of categories is greater + /// than 50% of the number of categorized documents, there are no frequently matched categories, or more than 50% of categories + /// are dead. + /// + [EnumMember(Value = "warn")] + Warn + } +} diff --git a/src/Nest/Cat/CatJobs/ModelMemoryStatus.cs b/src/Nest/Cat/CatJobs/ModelMemoryStatus.cs new file mode 100644 index 00000000000..1b423598493 --- /dev/null +++ b/src/Nest/Cat/CatJobs/ModelMemoryStatus.cs @@ -0,0 +1,30 @@ +using System.Runtime.Serialization; +using Elasticsearch.Net; + +namespace Nest +{ + /// + /// The status of the mathematical models + /// + [StringEnum] + public enum ModelMemoryStatus + { + /// + /// The models stayed below the configured value. + /// + [EnumMember(Value = "ok")] + OK, + + /// + /// The models used more than 60% of the configured memory limit and older unused models will be pruned to free up space. + /// + [EnumMember(Value = "soft_limit")] + SoftLimit, + + /// + /// The models used more space than the configured memory limit. As a result, not all incoming data was processed. + /// + [EnumMember(Value = "hard_limit")] + HardLimit + } +} diff --git a/src/Nest/Descriptors.Cat.cs b/src/Nest/Descriptors.Cat.cs index 2f962b4876f..1b14073e6a1 100644 --- a/src/Nest/Descriptors.Cat.cs +++ b/src/Nest/Descriptors.Cat.cs @@ -296,6 +296,42 @@ public partial class CatMasterDescriptor : RequestDescriptorBase Qs("v", verbose); } + ///Descriptor for Jobs https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + public partial class CatJobsDescriptor : RequestDescriptorBase, ICatJobsRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.CatJobs; + ////_cat/ml/anomaly_detectors + public CatJobsDescriptor(): base() + { + } + + ////_cat/ml/anomaly_detectors/{job_id} + ///Optional, accepts null + public CatJobsDescriptor(Id jobId): base(r => r.Optional("job_id", jobId)) + { + } + + // values part of the url path + Id ICatJobsRequest.JobId => Self.RouteValues.Get("job_id"); + ///The ID of the jobs stats to fetch + public CatJobsDescriptor JobId(Id jobId) => Assign(jobId, (a, v) => a.RouteValues.Optional("job_id", v)); + // Request parameters + ///Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + public CatJobsDescriptor AllowNoJobs(bool? allownojobs = true) => Qs("allow_no_jobs", allownojobs); + ///The unit in which to display byte values + public CatJobsDescriptor Bytes(Bytes? bytes) => Qs("bytes", bytes); + ///a short version of the Accept header, e.g. json, yaml + public CatJobsDescriptor Format(string format) => Qs("format", format); + ///Comma-separated list of column names to display + public CatJobsDescriptor Headers(params string[] headers) => Qs("h", headers); + ///Return help information + public CatJobsDescriptor Help(bool? help = true) => Qs("help", help); + ///Comma-separated list of column names or column aliases to sort by + public CatJobsDescriptor SortByColumns(params string[] sortbycolumns) => Qs("s", sortbycolumns); + ///Verbose mode. Display column headers + public CatJobsDescriptor Verbose(bool? verbose = true) => Qs("v", verbose); + } + ///Descriptor for TrainedModels https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html public partial class CatTrainedModelsDescriptor : RequestDescriptorBase, ICatTrainedModelsRequest { diff --git a/src/Nest/Descriptors.MachineLearning.cs b/src/Nest/Descriptors.MachineLearning.cs index 849416fc454..0a0e99125a8 100644 --- a/src/Nest/Descriptors.MachineLearning.cs +++ b/src/Nest/Descriptors.MachineLearning.cs @@ -251,7 +251,7 @@ protected DeleteModelSnapshotDescriptor(): base() // Request parameters } - ///Descriptor for EstimateModelMemory + ///Descriptor for EstimateModelMemory https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html public partial class EstimateModelMemoryDescriptor : RequestDescriptorBase, EstimateModelMemoryRequestParameters, IEstimateModelMemoryRequest>, IEstimateModelMemoryRequest { internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningEstimateModelMemory; diff --git a/src/Nest/ElasticClient.Cat.cs b/src/Nest/ElasticClient.Cat.cs index 196bb869f50..c21980b0a5a 100644 --- a/src/Nest/ElasticClient.Cat.cs +++ b/src/Nest/ElasticClient.Cat.cs @@ -229,6 +229,30 @@ internal CatNamespace(ElasticClient client): base(client) /// public Task> MasterAsync(ICatMasterRequest request, CancellationToken ct = default) => DoCatAsync(request, ct); /// + /// GET request to the cat.ml_jobs API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + /// + public CatResponse Jobs(Func selector = null) => Jobs(selector.InvokeOrDefault(new CatJobsDescriptor())); + /// + /// GET request to the cat.ml_jobs API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + /// + public Task> JobsAsync(Func selector = null, CancellationToken ct = default) => JobsAsync(selector.InvokeOrDefault(new CatJobsDescriptor()), ct); + /// + /// GET request to the cat.ml_jobs API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + /// + public CatResponse Jobs(ICatJobsRequest request) => DoCat(request); + /// + /// GET request to the cat.ml_jobs API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + /// + public Task> JobsAsync(ICatJobsRequest request, CancellationToken ct = default) => DoCatAsync(request, ct); + /// /// GET request to the cat.ml_trained_models API, read more about this API online: /// /// https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html diff --git a/src/Nest/ElasticClient.MachineLearning.cs b/src/Nest/ElasticClient.MachineLearning.cs index 4592050a560..227bf102d47 100644 --- a/src/Nest/ElasticClient.MachineLearning.cs +++ b/src/Nest/ElasticClient.MachineLearning.cs @@ -279,27 +279,27 @@ internal MachineLearningNamespace(ElasticClient client): base(client) /// /// POST request to the ml.estimate_model_memory API, read more about this API online: /// - /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html /// public EstimateModelMemoryResponse EstimateModelMemory(Func, IEstimateModelMemoryRequest> selector) where TDocument : class => EstimateModelMemory(selector.InvokeOrDefault(new EstimateModelMemoryDescriptor())); /// /// POST request to the ml.estimate_model_memory API, read more about this API online: /// - /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html /// public Task EstimateModelMemoryAsync(Func, IEstimateModelMemoryRequest> selector, CancellationToken ct = default) where TDocument : class => EstimateModelMemoryAsync(selector.InvokeOrDefault(new EstimateModelMemoryDescriptor()), ct); /// /// POST request to the ml.estimate_model_memory API, read more about this API online: /// - /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html /// public EstimateModelMemoryResponse EstimateModelMemory(IEstimateModelMemoryRequest request) => DoRequest(request, request.RequestParameters); /// /// POST request to the ml.estimate_model_memory API, read more about this API online: /// - /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html /// public Task EstimateModelMemoryAsync(IEstimateModelMemoryRequest request, CancellationToken ct = default) => DoRequestAsync(request, request.RequestParameters, ct); /// diff --git a/src/Nest/Requests.Cat.cs b/src/Nest/Requests.Cat.cs index ed1b4c7990c..cb0a34fe039 100644 --- a/src/Nest/Requests.Cat.cs +++ b/src/Nest/Requests.Cat.cs @@ -680,6 +680,90 @@ public bool? Verbose } } + [InterfaceDataContract] + public partial interface ICatJobsRequest : IRequest + { + [IgnoreDataMember] + Id JobId + { + get; + } + } + + ///Request for Jobs https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html + public partial class CatJobsRequest : PlainRequestBase, ICatJobsRequest + { + protected ICatJobsRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.CatJobs; + ////_cat/ml/anomaly_detectors + public CatJobsRequest(): base() + { + } + + ////_cat/ml/anomaly_detectors/{job_id} + ///Optional, accepts null + public CatJobsRequest(Id jobId): base(r => r.Optional("job_id", jobId)) + { + } + + // values part of the url path + [IgnoreDataMember] + Id ICatJobsRequest.JobId => Self.RouteValues.Get("job_id"); + // Request parameters + ///Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + public bool? AllowNoJobs + { + get => Q("allow_no_jobs"); + set => Q("allow_no_jobs", value); + } + + ///The unit in which to display byte values + public Bytes? Bytes + { + get => Q("bytes"); + set => Q("bytes", value); + } + + ///a short version of the Accept header, e.g. json, yaml + public string Format + { + get => Q("format"); + set + { + Q("format", value); + SetAcceptHeader(value); + } + } + + ///Comma-separated list of column names to display + public string[] Headers + { + get => Q("h"); + set => Q("h", value); + } + + ///Return help information + public bool? Help + { + get => Q("help"); + set => Q("help", value); + } + + ///Comma-separated list of column names or column aliases to sort by + public string[] SortByColumns + { + get => Q("s"); + set => Q("s", value); + } + + ///Verbose mode. Display column headers + public bool? Verbose + { + get => Q("v"); + set => Q("v", value); + } + } + [InterfaceDataContract] public partial interface ICatTrainedModelsRequest : IRequest { diff --git a/src/Nest/Requests.MachineLearning.cs b/src/Nest/Requests.MachineLearning.cs index eef5204ef81..904b9c82dd6 100644 --- a/src/Nest/Requests.MachineLearning.cs +++ b/src/Nest/Requests.MachineLearning.cs @@ -435,7 +435,7 @@ public partial interface IEstimateModelMemoryRequest : IRequestRequest for EstimateModelMemory + ///Request for EstimateModelMemory https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html public partial class EstimateModelMemoryRequest : PlainRequestBase, IEstimateModelMemoryRequest { protected IEstimateModelMemoryRequest Self => this; diff --git a/src/Nest/_Generated/ApiUrlsLookup.generated.cs b/src/Nest/_Generated/ApiUrlsLookup.generated.cs index c8e18b87d2a..f840bbd554e 100644 --- a/src/Nest/_Generated/ApiUrlsLookup.generated.cs +++ b/src/Nest/_Generated/ApiUrlsLookup.generated.cs @@ -33,7 +33,7 @@ internal static class ApiUrlsLookups internal static ApiUrls CatMaster = new ApiUrls(new[]{"_cat/master"}); internal static ApiUrls CatMlDataFrameAnalytics = new ApiUrls(new[]{"_cat/ml/data_frame/analytics", "_cat/ml/data_frame/analytics/{id}"}); internal static ApiUrls CatMlDatafeeds = new ApiUrls(new[]{"_cat/ml/datafeeds", "_cat/ml/datafeeds/{datafeed_id}"}); - internal static ApiUrls CatMlJobs = new ApiUrls(new[]{"_cat/ml/anomaly_detectors", "_cat/ml/anomaly_detectors/{job_id}"}); + internal static ApiUrls CatJobs = new ApiUrls(new[]{"_cat/ml/anomaly_detectors", "_cat/ml/anomaly_detectors/{job_id}"}); internal static ApiUrls CatTrainedModels = new ApiUrls(new[]{"_cat/ml/trained_models", "_cat/ml/trained_models/{model_id}"}); internal static ApiUrls CatNodeAttributes = new ApiUrls(new[]{"_cat/nodeattrs"}); internal static ApiUrls CatNodes = new ApiUrls(new[]{"_cat/nodes"}); diff --git a/tests/Tests/Cat/CatJobs/CatJobsApiTests.cs b/tests/Tests/Cat/CatJobs/CatJobsApiTests.cs new file mode 100644 index 00000000000..f43549643ba --- /dev/null +++ b/tests/Tests/Cat/CatJobs/CatJobsApiTests.cs @@ -0,0 +1,38 @@ +using System; +using System.Linq; +using Elastic.Xunit.XunitPlumbing; +using Elasticsearch.Net; +using Nest; +using Tests.Core.Extensions; +using Tests.Domain; +using Tests.Framework.EndpointTests.TestState; +using Tests.XPack.MachineLearning; + +namespace Tests.Cat.CatJobs +{ + [SkipVersion("<7.7.0", "Introduced in 7.7.0")] + public class CatJobsApiTests + : MachineLearningIntegrationTestBase, ICatJobsRequest, CatJobsDescriptor, CatJobsRequest> + { + public CatJobsApiTests(MachineLearningCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) + { + foreach (var callUniqueValue in values) PutJob(client, callUniqueValue.Value); + } + + protected override bool ExpectIsValid => true; + protected override int ExpectStatusCode => 200; + protected override HttpMethod HttpMethod => HttpMethod.GET; + protected override string UrlPath => "_cat/ml/anomaly_detectors"; + + protected override LazyResponses ClientUsage() => Calls( + (client, f) => client.Cat.Jobs(), + (client, f) => client.Cat.JobsAsync(), + (client, r) => client.Cat.Jobs(r), + (client, r) => client.Cat.JobsAsync(r) + ); + + protected override void ExpectResponse(CatResponse response) => response.ShouldBeValid(); + } +} diff --git a/tests/Tests/Cat/CatJobs/CatJobsUrlTests.cs b/tests/Tests/Cat/CatJobs/CatJobsUrlTests.cs new file mode 100644 index 00000000000..264ff33f1ce --- /dev/null +++ b/tests/Tests/Cat/CatJobs/CatJobsUrlTests.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using Elastic.Xunit.XunitPlumbing; +using Nest; +using Tests.Framework.EndpointTests; +using static Tests.Framework.EndpointTests.UrlTester; + +namespace Tests.Cat.CatJobs +{ + public class CatJobsUrlTests : UrlTestsBase + { + [U] + public override async Task Urls() + { + await GET("/_cat/ml/anomaly_detectors") + .Fluent(c => c.Cat.Jobs()) + .Request(c => c.Cat.Jobs(new CatJobsRequest())) + .FluentAsync(c => c.Cat.JobsAsync()) + .RequestAsync(c => c.Cat.JobsAsync(new CatJobsRequest())); + + await GET("/_cat/ml/anomaly_detectors/job-id") + .Fluent(c => c.Cat.Jobs(f => f.JobId("job-id"))) + .Request(c => c.Cat.Jobs(new CatJobsRequest("job-id"))) + .FluentAsync(c => c.Cat.JobsAsync(f => f.JobId("job-id"))) + .RequestAsync(c => c.Cat.JobsAsync(new CatJobsRequest("job-id"))); + } + } +}